From 2a7a3a557f1f5977a01b048ede95e7f3468a62c2 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sun, 21 Apr 2013 00:42:34 +0900 Subject: [PATCH] e17 mixer - use XDG_RUNTIME_DIR for finding pulse... and have more generous fallbacks. --- src/modules/mixer/pa.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/modules/mixer/pa.c b/src/modules/mixer/pa.c index a128662..a13b35e 100644 --- a/src/modules/mixer/pa.c +++ b/src/modules/mixer/pa.c @@ -713,13 +713,37 @@ pulse_new(void) if (!prev) { struct stat st; - buf = eina_stringshare_add(STATEDIR "/run/pulse/native"); - if (stat(buf, &st)) + char *s; + + s = getenv("XDG_RUNTIME_DIR"); + buf = eina_stringshare_add(s); + if ((!s) || ((buf) && (stat(buf, &st)))) { - INF("could not locate local socket '%s'!", buf); - free(conn); - return NULL; + snprintf(h, sizeof(h), "/run/user/%i/pulse/native", + (int)getuid()); + if (stat(h, &st)) + { + snprintf(h, sizeof(h), "%s/run/user/%i/pulse/native", + STATEDIR, (int)getuid()); + if (stat(h, &st)) + { + buf = eina_stringshare_add(STATEDIR "/run/pulse/native"); + if (stat(buf, &st)) + { + eina_stringshare_del(buf); + INF("could not locate local socket '%s'!", buf); + free(conn); + return NULL; + } + } + else + buf = eina_stringshare_add(h); + } + else + buf = eina_stringshare_add(h); } + else + buf = eina_stringshare_add(h); conn->socket = buf; } else conn->socket = prev; -- 2.7.4