Index: gnome-session/gsm-sound.c =================================================================== --- gnome-session/gsm-sound.c.orig +++ gnome-session/gsm-sound.c @@ -10,6 +10,8 @@ #include "util.h" #include +#include +#include #define ENABLE_SOUND_KEY "/desktop/gnome/sound/enable_esd" #define ENABLE_EVENT_SOUNDS_KEY "/desktop/gnome/sound/event_sounds" @@ -69,7 +71,7 @@ reset_esd_pid (GPid pid, static void start_esd (void) { - gchar *argv[] = {ESD_SERVER, "-nobeeps", NULL}; + gchar *argv[] = {ESD_SERVER, "-terminate", "-nobeeps", NULL}; GError *err = NULL; time_t starttime; @@ -93,6 +95,81 @@ start_esd (void) } } + +static gboolean +load_login_sample_from (const char *file, + gboolean *isset) +{ + char *key; + char *sample_file; + int sample_id; + + if (!file) + return FALSE; + + key = g_strconcat ("=", file, "=login/file", NULL); + sample_file = gnome_config_get_string (key); + g_free (key); + + if (sample_file && isset) + *isset = TRUE; + else if (isset) + *isset = FALSE; + + if (sample_file && *sample_file && *sample_file != '/') + { + char *tmp_sample_file; + tmp_sample_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_SOUND, sample_file, TRUE, NULL); + g_free (sample_file); + sample_file = tmp_sample_file; + } + + if (!(sample_file && *sample_file)) + { + g_free (sample_file); + return FALSE; + } + + sample_id = esd_sample_getid (gnome_sound_connection_get (), "gnome-2/login"); + if (sample_id >= 0) + esd_sample_free (gnome_sound_connection_get (), sample_id); + + sample_id = gnome_sound_sample_load ("gnome-2/login", sample_file); + + if (sample_id < 0) + { + g_warning ("Couldn't load sound file %s\n", sample_file); + return FALSE; + } + + g_free (sample_file); + + return TRUE; +} + +#define SOUND_EVENT_FILE "sound/events/gnome-2.soundlist" + static gboolean +load_login_sample (void) +{ + char *s; + gboolean loaded; + gboolean isset; + + s = gnome_util_home_file (SOUND_EVENT_FILE); + loaded = load_login_sample_from (s, &isset); + g_free (s); + + if (isset) + return loaded; + + s = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_CONFIG, SOUND_EVENT_FILE, TRUE, NULL); + loaded = load_login_sample_from (s, NULL); + g_free (s); + + return loaded; +} + + static void stop_esd (void) { @@ -126,7 +203,7 @@ sound_init (void) return FALSE; } - return TRUE; + return load_login_sample(); } static void @@ -229,6 +306,4 @@ gsm_sound_logout (void) { if (sound_events_enabled ()) play_sound_event ("logout"); - - sound_shutdown (); }