hdajackretask: Fix killing PulseAudio on newer PulseAudio versions
authorDavid Henningsson <david.henningsson@canonical.com>
Thu, 13 Jun 2013 14:26:43 +0000 (16:26 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 14 Jun 2013 12:08:14 +0000 (14:08 +0200)
The standard configuration directory for PulseAudio has changed,
I think since 3.0. Adjust the directory lookup mechanism to match.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

hdajackretask/apply-changes.c

index eda404e..840f649 100644 (file)
@@ -97,7 +97,20 @@ gboolean run_sudo_script(const gchar* script_name, GError** err)
 
 static gchar* get_pulseaudio_client_conf()
 {
-    return g_strdup_printf("%s/.pulse/client.conf", g_get_home_dir());
+    /* Reference: See src/pulsecore/core-util.c in pulseaudio */
+    gchar* fname;
+    gchar* dir = g_strdup_printf("%s/.pulse", g_get_home_dir());
+    if (access(dir, F_OK) < 0) {
+       const gchar* xch = g_getenv("XDG_CONFIG_HOME");
+       g_free(dir);
+       if (xch)
+           dir = g_strdup_printf("%s/pulse", xch);
+       else
+           dir = g_strdup_printf("%s/.config/pulse", g_get_home_dir());
+    }
+    fname = g_strdup_printf("%s/client.conf", dir);
+    g_free(dir);
+    return fname;
 }
 
 static gboolean kill_pulseaudio(gboolean* was_killed, int card, GError** err)