Index: gnome-session/gsm-gsd.c
===================================================================
--- gnome-session/gsm-gsd.c	(revision 4584)
+++ gnome-session/gsm-gsd.c	(working copy)
@@ -1,6 +1,7 @@
 #include <config.h>
 
 #include "gsm-gsd.h"
+#include "gsm-sound.h"
 #include "util.h"
 
 #include <time.h>
@@ -111,6 +112,18 @@
     }
 }
 
+static void
+plugin_activated (DBusGProxy *proxy,
+		  const char *name,
+		  GnomeSettingsData *gsd)
+{
+  if (name == NULL || strcmp (name, "sound") != 0)
+    return;
+
+  /* Play the login sound when the session is activated */
+  gsm_sound_login ();
+}
+
 void
 gsm_gsd_start (void)
 {
@@ -172,6 +185,20 @@
         } 
       else
         {
+          /* Connect to the signal before we wake the settings daemon
+           * up, otherwise, it might have the sound system ready before
+           * we're actually listening */
+	  dbus_g_proxy_add_signal (gsd.dbus_proxy,
+				   "PluginActivated",
+				   G_TYPE_STRING,
+				   G_TYPE_INVALID);
+
+	  dbus_g_proxy_connect_signal (gsd.dbus_proxy,
+				       "PluginActivated",
+				       G_CALLBACK (plugin_activated),
+				       &gsd,
+				       NULL);
+
           if (!org_gnome_SettingsDaemon_awake(gsd.dbus_proxy, &error))
             {
               /* Method failed, the GError is set, let's warn everyone */
@@ -199,6 +226,7 @@
                                            G_CALLBACK (name_owner_changed),
                                            &gsd,
                                            NULL);
+
             }
         }
     }
Index: gnome-session/gsm-sound.c
===================================================================
--- gnome-session/gsm-sound.c	(revision 4584)
+++ gnome-session/gsm-sound.c	(working copy)
@@ -4,9 +4,6 @@
 
 #include <signal.h>
 #include <unistd.h>
-#ifdef HAVE_ESD
-#include <esd.h>
-#endif
 #include "util.h"
 
 #include <libgnome/libgnome.h>
@@ -54,60 +51,6 @@
   return retval;
 }
 
-#ifdef HAVE_ESD
-static GPid esd_pid = 0;
-
-static void
-reset_esd_pid (GPid     pid,
-	       gint     status,
-	       gpointer ignore)
-{
-  if (pid == esd_pid)
-    esd_pid = 0;
-}
-
-static void
-start_esd (void) 
-{
-  gchar  *argv[] = {ESD_SERVER, "-nobeeps", NULL};
-  GError *err = NULL;
-  time_t  starttime;
-
-  if (!gsm_exec_async (NULL, argv, NULL, &esd_pid, &err))
-    {
-      g_warning ("Could not start esd: %s\n", err->message);
-      g_error_free (err);
-      return;
-    }
-
-  g_child_watch_add (esd_pid, reset_esd_pid, NULL);
-
-  starttime = time (NULL);
-  gnome_sound_init (NULL);
-
-  while (gnome_sound_connection_get () < 0
-	 && ((time (NULL) - starttime) < 4))
-    {
-      g_usleep (200);
-      gnome_sound_init (NULL);
-    }
-}
-
-static void
-stop_esd (void)
-{
-  gnome_sound_shutdown ();
-
-  if (esd_pid)
-    {
-      if (kill (esd_pid, SIGTERM) == -1)
-        g_printerr ("Failed to kill esd (pid %d)\n", esd_pid);
-      else
-        esd_pid = 0;
-    }
-}
-#endif /* HAVE_ESD */
-
 static gboolean
 sound_init (void)
 {
@@ -115,103 +58,16 @@
   if (!sound_enabled ())
     return FALSE;
 
-#ifdef HAVE_ESD
   if (gnome_sound_connection_get () < 0)
-    start_esd ();
-#endif
+    return FALSE;
 
-  if (gnome_sound_connection_get () < 0)
-    {
-      g_warning ("Failed to start sound.\n");
-      return FALSE;
-    }
-
   return TRUE;
 }
 
-static void 
-sound_shutdown (void)
-{
-#ifdef HAVE_ESD
-  stop_esd ();
-#endif
-}
-
-static char *
-get_filename_from_string (const char *string)
-{
-  if (string[0] != '/')
-    {
-      return gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_SOUND, string,
-					TRUE, NULL);
-    }
-
-  return g_strdup (string);
-}
-
-static char *
-get_filename_for_sound_from_keyfile (const char *name, const char *soundlist_file)
-{
-  GKeyFile *keyfile;
-  char *sound;
-
-  keyfile = g_key_file_new ();
-
-  if (g_key_file_load_from_file (keyfile, soundlist_file, G_KEY_FILE_NONE, NULL) == FALSE)
-    {
-      g_key_file_free (keyfile);
-      return NULL;
-    }
-
-  sound = g_key_file_get_string (keyfile, name, "file", NULL);
-  g_key_file_free (keyfile);
-  if (sound != NULL)
-    {
-      char *res;
-
-      res = get_filename_from_string (sound);
-      if (res != NULL)
-        {
-          g_free (sound);
-	  return res;
-	}
-    }
-  g_free (sound);
-
-  return NULL;
-}
-
-static char *
-get_filename_for_sound (const char *name)
-{
-  char *soundlist, *sound;
-
-  /* Try to load the user configuration first */
-  soundlist = g_build_filename (g_get_home_dir(), ".gnome2", "sound",
-				"events", "gnome-2.soundlist", NULL);
-  sound = get_filename_for_sound_from_keyfile (name, soundlist);
-  g_free (soundlist);
-  if (sound != NULL)
-    return sound;
-
-  soundlist = g_build_filename (SYSCONFDIR, "sound", "events", "gnome-2.soundlist", NULL);
-  sound = get_filename_for_sound_from_keyfile (name, soundlist);
-  g_free (soundlist);
-
-  return sound;
-}
-
 static void
 play_sound_event (const char *name)
 {
-  char *sound;
-
-  sound = get_filename_for_sound (name);
-  if (sound != NULL)
-    {
-      gnome_sound_play (sound);
-      g_free (sound);
-    }
+  gnome_triggers_do (NULL, NULL, "gnome-2", name, NULL);
 }
 
 void 
@@ -230,5 +86,6 @@
   if (sound_events_enabled ())
     play_sound_event ("logout");
 
-  sound_shutdown ();
+  gnome_sound_shutdown ();
 }
+
Index: gnome-session/main.c
===================================================================
--- gnome-session/main.c	(revision 4584)
+++ gnome-session/main.c	(working copy)
@@ -776,8 +776,6 @@
   g_setenv ("GNOME_DESKTOP_SESSION_ID", session_name, TRUE);
   the_session = read_session (session_name);
 
-  gsm_sound_login ();
-
   gsm_remote_desktop_start ();
 
   if (splashing)
Index: gnome-session/Makefile.am
===================================================================
--- gnome-session/Makefile.am	(revision 4584)
+++ gnome-session/Makefile.am	(working copy)
@@ -14,7 +14,6 @@
 	-DRSH_COMMAND=\""$(RSH_COMMAND)\""		\
 	-DGCONFTOOL_CMD=\""$(GCONFTOOL)\""		\
 	-DDEFAULTDIR="\"$(defaultdir)\""		\
-	-DESD_SERVER="\"$(ESD_SERVER)\""		\
 	-DAT_SPI_REGISTRYD_DIR="\"$(AT_SPI_REGISTRYD_DIR)\""	\
 	-DTIME_UTILITY="\"$(TIME_UTILITY)\""		\
 	-DSYSCONFDIR=\""$(sysconfdir)"\"
Index: configure.in
===================================================================
--- configure.in	(revision 4584)
+++ configure.in	(working copy)
@@ -51,7 +51,6 @@
    AC_SUBST([DISABLE_DEPRECATED_CFLAGS])
 fi
 
-ESOUND_REQUIRED=0.2.26
 GLIB_REQUIRED=2.13.0
 LIBGNOMEUI_REQUIRED=2.2.0
 GTK_REQUIRED=2.11.1
@@ -62,41 +61,8 @@
 
 PKG_PROG_PKG_CONFIG()
 
-dnl We first check for esound and audiofile (which has conditional
-dnl support built in)
+PKG_CHECK_MODULES(GNOME_SESSION, glib-2.0 >= $GLIB_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gnome-settings-daemon gnome-keyring-1 >= $GNOME_KEYRING_REQUIRED)
 
-AC_MSG_CHECKING([whether ESounD support is requested])
-AC_ARG_ENABLE([esd],
-	AS_HELP_STRING([--enable-esd],[Enable ESounD (default=yes)]),
-	[enable_esd=$enableval],
-	[enable_esd=yes])
-AC_MSG_RESULT([$enable_esd])
-
-if test x$enable_esd = xyes; then
-	ESOUND_MODULE="esound >= $ESOUND_REQUIRED"
-	PKG_CHECK_MODULES(ESOUND, $ESOUND_MODULE)
-	AC_DEFINE(HAVE_ESD, 1, [Define if you have the ESound Daemon])
-
-	ESDSERVERDIR=`$PKG_CONFIG --variable=esd_serverdir esound`
-	old_path=$PATH
-	if test x"$ESDSERVERDIR" != x; then
-		PATH=$ESDSERVERDIR:$PATH
-	fi
-
-	AC_PATH_PROG(ESD_SERVER, esd, no)
-	if test x"$ESD_SERVER" = xno; then
-		AC_MSG_ERROR([esd executable not found in your path - should be installed with ESound])
-	fi
-
-	AC_SUBST(ESD_SERVER)
-	PATH=$old_path
-
-else
-	ESOUND_MODULE=""
-fi
-
-PKG_CHECK_MODULES(GNOME_SESSION, glib-2.0 >= $GLIB_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED $ESOUND_MODULE dbus-glib-1 >= $DBUS_GLIB_REQUIRED gnome-settings-daemon gnome-keyring-1 >= $GNOME_KEYRING_REQUIRED)
-
 dnl Check if libnotify is present
 
 LIBNOTIFY_REQUIRED=0.2.1
