summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/proplist-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore/proplist-util.c')
-rw-r--r--src/pulsecore/proplist-util.c63
1 files changed, 53 insertions, 10 deletions
diff --git a/src/pulsecore/proplist-util.c b/src/pulsecore/proplist-util.c
index 35c9985a..522c7afe 100644
--- a/src/pulsecore/proplist-util.c
+++ b/src/pulsecore/proplist-util.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <locale.h>
+#include <dlfcn.h>
#include <pulse/proplist.h>
#include <pulse/utf8.h>
@@ -36,11 +37,11 @@
#include "proplist-util.h"
void pa_init_proplist(pa_proplist *p) {
- int a, b;
#if !HAVE_DECL_ENVIRON
extern char **environ;
#endif
char **e;
+ const char *pp;
pa_assert(p);
@@ -75,6 +76,15 @@ void pa_init_proplist(pa_proplist *p) {
}
}
+ if ((pp = getenv("PULSE_PROP"))) {
+ pa_proplist *t;
+
+ if ((t = pa_proplist_from_string(pp))) {
+ pa_proplist_update(p, PA_UPDATE_MERGE, t);
+ pa_proplist_free(t);
+ }
+ }
+
if (!pa_proplist_contains(p, PA_PROP_APPLICATION_PROCESS_ID)) {
char t[32];
pa_snprintf(t, sizeof(t), "%lu", (unsigned long) getpid());
@@ -99,22 +109,36 @@ void pa_init_proplist(pa_proplist *p) {
}
}
- a = pa_proplist_contains(p, PA_PROP_APPLICATION_PROCESS_BINARY);
- b = pa_proplist_contains(p, PA_PROP_APPLICATION_NAME);
-
- if (!a || !b) {
+ if (!pa_proplist_contains(p, PA_PROP_APPLICATION_PROCESS_BINARY)) {
char t[PATH_MAX];
if (pa_get_binary_name(t, sizeof(t))) {
char *c = pa_utf8_filter(t);
+ pa_proplist_sets(p, PA_PROP_APPLICATION_PROCESS_BINARY, c);
+ pa_xfree(c);
+ }
+ }
- if (!a)
- pa_proplist_sets(p, PA_PROP_APPLICATION_PROCESS_BINARY, c);
- if (!b)
- pa_proplist_sets(p, PA_PROP_APPLICATION_NAME, c);
+#ifdef RTLD_NOLOAD
+ if (!pa_proplist_contains(p, PA_PROP_APPLICATION_NAME)) {
+ void *dl;
- pa_xfree(c);
+ if ((dl = dlopen("libglib-2.0", RTLD_NOLOAD))) {
+ const char *(*_g_get_application_name)(void);
+
+ if ((*(void**) &_g_get_application_name = dlsym(dl, "g_get_application_name")))
+ pa_proplist_sets(p, PA_PROP_APPLICATION_NAME, _g_get_application_name());
+
+ dlclose(dl);
}
}
+#endif
+
+ if (!pa_proplist_contains(p, PA_PROP_APPLICATION_NAME)) {
+ const char *t;
+
+ if ((t = pa_proplist_gets(p, PA_PROP_APPLICATION_PROCESS_BINARY)))
+ pa_proplist_sets(p, PA_PROP_APPLICATION_NAME, t);
+ }
if (!pa_proplist_contains(p, PA_PROP_APPLICATION_LANGUAGE)) {
const char *l;
@@ -122,4 +146,23 @@ void pa_init_proplist(pa_proplist *p) {
if ((l = setlocale(LC_MESSAGES, NULL)))
pa_proplist_sets(p, PA_PROP_APPLICATION_LANGUAGE, l);
}
+
+ if (!pa_proplist_contains(p, PA_PROP_WINDOW_X11_DISPLAY)) {
+ const char *t;
+
+ if ((t = getenv("DISPLAY"))) {
+ char *c = pa_utf8_filter(t);
+ pa_proplist_sets(p, PA_PROP_WINDOW_X11_DISPLAY, c);
+ pa_xfree(c);
+ }
+ }
+
+ if (!pa_proplist_contains(p, PA_PROP_APPLICATION_PROCESS_MACHINE_ID)) {
+ char *m;
+
+ if ((m = pa_machine_id())) {
+ pa_proplist_sets(p, PA_PROP_APPLICATION_PROCESS_MACHINE_ID, m);
+ pa_xfree(m);
+ }
+ }
}