Hi,

Currently the process to play login sound holds gnome-session into Desktop
phase until it times out and goes to next level.  This sucks.  I'm fixing
gnome-session to recognize process terminates as "done".  The other half of
the fix is to play the sound in a background process.  Attached patch adds a
--background option to canberra-gkt-play (only if unistd.h is available.  One
can try writing it portably using g_spawn.) and uses that in the autostart file.

behdad
diff -up libcanberra-0.10/src/canberra-gtk-play.c.behdad 
libcanberra-0.10/src/canberra-gtk-play.c
--- libcanberra-0.10/src/canberra-gtk-play.c.behdad     2008-12-07 
20:28:59.000000000 -0500
+++ libcanberra-0.10/src/canberra-gtk-play.c    2008-12-07 23:52:14.000000000 
-0500
@@ -26,9 +26,16 @@
 #include <canberra-gtk.h>
 #include <locale.h>
 
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#endif
+
 static int ret = 0;
 static ca_proplist *proplist = NULL;
 static int n_loops = 1;
+static gboolean background = FALSE;
 
 static void callback(ca_context *c, uint32_t id, int error, void *userdata);
 
@@ -88,6 +95,9 @@ int main (int argc, char *argv[]) {
         { "id",            'i', 0, G_OPTION_ARG_STRING, &event_id,          
"Event sound identifier",  "STRING" },
         { "file",          'f', 0, G_OPTION_ARG_STRING, &filename,          
"Play file",  "PATH" },
         { "description",   'd', 0, G_OPTION_ARG_STRING, &event_description, 
"Event sound description", "STRING" },
+#if HAVE_UNISTD_H
+        { "background",    'b', 0, G_OPTION_ARG_NONE,   &background,        
"Run in background", NULL },
+#endif
         { "cache-control", 'c', 0, G_OPTION_ARG_STRING, &cache_control,     
"Cache control (permanent, volatile, never)", "STRING" },
         { "loop",          'l', 0, G_OPTION_ARG_INT,    &n_loops,           
"Loop how many times (detault: 1)", "INTEGER" },
        { "version",       'v', 0, G_OPTION_ARG_NONE,   &version,           
"Display version number and quit", NULL },
@@ -116,6 +126,24 @@ int main (int argc, char *argv[]) {
         return 1;
     }
 
+#if HAVE_UNISTD_H
+    if (background) {
+        switch (fork ()) {
+        case -1:
+                g_error ("Fork failed: %s", g_strerror (errno));
+                exit (EXIT_FAILURE);
+
+        case 0:
+                /* child */
+               break;
+
+         default:
+                /* parent */
+                exit (EXIT_SUCCESS);
+        }
+    }
+#endif
+
     ca_context_change_props(ca_gtk_context_get(),
                             CA_PROP_APPLICATION_NAME, "canberra-gtk-play",
                             CA_PROP_APPLICATION_ID, 
"org.freedesktop.libcanberra.GtkPlay",
diff -up libcanberra-0.10/src/libcanberra-login-sound.desktop.behdad 
libcanberra-0.10/src/libcanberra-login-sound.desktop
--- libcanberra-0.10/src/libcanberra-login-sound.desktop.behdad 2008-12-07 
20:52:35.000000000 -0500
+++ libcanberra-0.10/src/libcanberra-login-sound.desktop        2008-12-07 
20:53:03.000000000 -0500
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Type=Application
 Name=GNOME Login Sound
-Exec=/usr/bin/canberra-gtk-play --id="desktop-login" --description="GNOME 
Login"
+Exec=/usr/bin/canberra-gtk-play --background --id="desktop-login" 
--description="GNOME Login"
 OnlyShowIn=GNOME;
 AutostartCondition=GNOME /desktop/gnome/sound/event_sounds
 X-GNOME-Autostart-Phase=Desktop
_______________________________________________
libcanberra-discuss mailing list
[email protected]
https://tango.0pointer.de/mailman/listinfo/libcanberra-discuss

Reply via email to