=== modified file 'Makefile.am'
--- Makefile.am	
+++ Makefile.am	
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = po src help
+SUBDIRS = po libguniqueapp src help
 
 EXTRA_DIST = \
 	gnome-system-monitor.desktop.in \
=== modified file 'configure.in'
--- configure.in	
+++ configure.in	
@@ -67,9 +67,35 @@ AM_GLIB_GNU_GETTEXT
 dnl Set PACKAGE_LOCALE_DIR in config.h.
 GLIB_DEFINE_LOCALEDIR(PACKAGE_LOCALE_DIR)
 
+dnl Guniqueapp stuff
+
+GTK_RECCOMENDED=2.12.0
+DBUS_GLIB_REQUIRED=0.33
+
+if $PKG_CONFIG --atleast-version $GTK_RECCOMENDED gtk+-2.0; then
+   have_recent_gtk=yes
+else
+   have_recent_gtk=no
+   AC_DEFINE(OLDER_GTK_VERSION, , [Building with GTK+ older than 2.12]) 
+fi
+
+if $PKG_CONFIG --atleast-version $DBUS_GLIB_REQUIRED dbus-glib-1; then
+   have_dbus=yes
+   PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= $DBUS_GLIB_REQUIRED)
+   AC_SUBST(DBUS_CFLAGS)
+   AC_SUBST(DBUS_LIBS)
+   AC_DEFINE(HAVE_DBUS, , [Building with DBus support]) 
+   AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool)
+else
+   have_dbus=no
+fi
+
+AM_CONDITIONAL([HAVE_DBUS], [test $have_dbus = yes])
+AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
 
 AC_CONFIG_FILES([
 Makefile
+libguniqueapp/Makefile
 src/Makefile
 po/Makefile.in
 help/Makefile
=== modified file 'src/Makefile.am'
--- src/Makefile.am	
+++ src/Makefile.am	
@@ -3,7 +3,8 @@
 INCLUDES = \
 	-DPROCMAN_DATADIR=\"$(datadir)/procman/\" \
 	-DDATADIR=\""$(datadir)"\" \
-	@PROCMAN_CFLAGS@
+	@PROCMAN_CFLAGS@ \
+	-I../libguniqueapp
 
 bin_PROGRAMS = gnome-system-monitor
 
@@ -29,14 +30,11 @@ gnome_system_monitor_SOURCES = \
 	e_date.c e_date.h
 
 
-gnome_system_monitor_LDADD = @PROCMAN_LIBS@ libbacon.la 
-
-
-noinst_LTLIBRARIES = libbacon.la
-libbacon_la_SOURCES = \
-	bacon-message-connection.c \
-	bacon-message-connection.h
+gnome_system_monitor_LDADD = @PROCMAN_LIBS@ ../libguniqueapp/libguniqueapp.la
 
+if HAVE_DBUS
+gnome_system_monitor_LDADD += @DBUS_LIBS@
+endif
 
 specdir = $(datadir)/procman
 
=== modified file 'src/procman.c'
--- src/procman.c	
+++ src/procman.c	
@@ -26,7 +26,7 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
 #include <gnome.h>
-#include <bacon-message-connection.h>
+#include <guniqueapp.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <gconf/gconf-client.h>
 #include <glibtop.h>
@@ -578,61 +578,14 @@ procman_save_config (ProcData *data)
 	
 }
 
-static guint32
-get_startup_timestamp ()
-{
-	const gchar *startup_id_env;
-	gchar *startup_id = NULL;
-	gchar *time_str;
-	gulong retval = 0;
-
-	/* we don't unset the env, since startup-notification
-	 * may still need it */
-	startup_id_env = g_getenv ("DESKTOP_STARTUP_ID");
-	if (startup_id_env == NULL)
-		goto out;
-
-	startup_id = g_strdup (startup_id_env);
-
-	time_str = g_strrstr (startup_id, "_TIME");
-	if (time_str == NULL)
-		goto out;
-
-	/* Skip past the "_TIME" part */
-	time_str += 5;
-
-	retval = strtoul (time_str, NULL, 0);
-
- out:
-	g_free (startup_id);
-
-	return retval;
-}
-
 
 static void
-cb_server (const gchar *msg, gpointer user_data)
+cb_server (GUniqueApp *app, GUniqueAppCommand command, gchar* data, gchar* startup_id, guint workspace, gpointer user_data)
 {
-	GdkWindow *window;
 	ProcData *procdata;
-	guint32 timestamp;
-
-	window = gdk_get_default_root_window ();
-
 	procdata = *(ProcData**)user_data;
-	g_assert (procdata != NULL);
-
-	timestamp = strtoul(msg, NULL, 0);
-
-	if (timestamp == 0)
-	{
-		/* fall back to rountripping to X */
-		timestamp = gdk_x11_get_server_time (window);
-	}
-
-	gdk_x11_window_set_user_time (window, timestamp);
-
-	gtk_window_present (GTK_WINDOW(procdata->app));
+	
+	gtk_window_set_startup_id (GTK_WINDOW(procdata->app), startup_id);
 }
 
 
@@ -653,44 +606,40 @@ init_volume_monitor(ProcData *procdata)
 int
 main (int argc, char *argv[])
 {
-	guint32 startup_timestamp;
 	GnomeProgram *procman;
 	GConfClient *client;
 	ProcData *procdata;
-	BaconMessageConnection *conn;
-
+	GUniqueApp *app;
+	gchar* startup_id = NULL;
+	
+#ifdef OLDER_GTK_VERSION
+	startup_id = g_getenv ("DESKTOP_STARTUP_ID");
+#endif	
+	
 	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
-	startup_timestamp = get_startup_timestamp();
 
 	procman = gnome_program_init ("gnome-system-monitor", VERSION, 
 				       LIBGNOMEUI_MODULE, argc, argv,
 				      GNOME_PARAM_APP_DATADIR,DATADIR, NULL);
+	
+	app = g_unique_app_get_with_startup_id ("gnome-system-monitor", startup_id);		      
+	
+	if (g_unique_app_is_running (app))
+	{		
+		g_unique_app_activate (app);
+		
+#ifdef OLDER_GTK_VERSION
+		gdk_notify_startup_complete (); 
+#endif
 
-	conn = bacon_message_connection_new ("gnome-system-monitor");
-	if (!conn) g_error("Couldn't connect to gnome-system-monitor");
-
-	if (bacon_message_connection_get_is_server (conn))
-	{
-		bacon_message_connection_set_callback (conn, cb_server, &procdata);
-	}
-	else /* client */
-	{
-		char *timestamp;
-
-		timestamp = g_strdup_printf ("%" G_GUINT32_FORMAT, startup_timestamp);
-
-		bacon_message_connection_send (conn, timestamp);
-
-		gdk_notify_startup_complete ();
-
-		g_free (timestamp);
-		bacon_message_connection_free (conn);
-
-		exit (0);
+		g_object_unref (app);
+		exit(0);
 	}
+	
+	else g_signal_connect (G_OBJECT (app), "message", (GCallback) cb_server, &procdata);
 
 	gtk_window_set_default_icon_name ("utilities-system-monitor");
 	g_set_application_name(_("System Monitor"));
@@ -723,6 +672,8 @@ main (int argc, char *argv[])
 
 	glibtop_close ();
 	gnome_vfs_shutdown ();
+	
+	g_object_unref (app);
 
 	return 0;
 }
