diff --git a/Tomboy.mdp b/Tomboy.mdp
index e1e2134..4b0041c 100644
--- a/Tomboy.mdp
+++ b/Tomboy.mdp
@@ -140,6 +140,7 @@
     <File name="Tomboy/Services.cs" subtype="Code" buildaction="Compile" />
     <File name="Tomboy/GConfPreferencesClient.cs" subtype="Code" buildaction="Compile" />
     <File name="Tomboy/GnomeApplication.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/GnomeSession.cs" subtype="Code" buildaction="Compile" />
     <File name="Tomboy/Keybinder.cs" subtype="Code" buildaction="Compile" />
     <File name="Tomboy/NativeApplication.cs" subtype="Code" buildaction="Compile" />
     <File name="Tomboy/PlatformFactory.cs" subtype="Code" buildaction="Compile" />
@@ -207,6 +208,8 @@
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
     <ProjectReference type="Gac" localcopy="True" refto="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
     <ProjectReference type="Gac" localcopy="True" refto="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+    <ProjectReference type="Gac" localcopy="True" refto="NDesk.DBus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f6716e4f9b2ed099" />
+    <ProjectReference type="Gac" localcopy="True" refto="NDesk.DBus.GLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f6716e4f9b2ed099" />
   </References>
   <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" ExecuteTargetName="run">
     <BuildFilesVar />
diff --git a/Tomboy/GnomeApplication.cs b/Tomboy/GnomeApplication.cs
index 5c1a655..e424791 100644
--- a/Tomboy/GnomeApplication.cs
+++ b/Tomboy/GnomeApplication.cs
@@ -9,6 +9,9 @@ using Mono.Unix.Native;
 
 using Hyena;
 
+using NDesk.DBus;
+using org.gnome.SessionManager;
+
 namespace Tomboy
 {
 	public class GnomeApplication : INativeApplication
@@ -17,6 +20,7 @@ namespace Tomboy
 		private static string confDir;
 		private static string dataDir;
 		private static string cacheDir;
+		private static ObjectPath session_client_id;
 		private const string tomboyDirName = "tomboy";
 
 		static GnomeApplication ()
@@ -45,43 +49,42 @@ namespace Tomboy
 			try {
 				SetProcessName (process_name);
 			} catch {} // Ignore exception if fail (not needed to run)
+			
+			// Register handler for saving session when logging out of Gnome
+			BusG.Init();
+			string startup_id = Environment.GetEnvironmentVariable("DESKTOP_AUTOSTART_ID");
+			if (String.IsNullOrEmpty(startup_id))
+			{
+				startup_id = "Tomboy";
+			}
+			
+			try
+			{
+				SessionManager session = Bus.Session.GetObject<SessionManager>("org.gnome.SessionManager", new ObjectPath("/org/gnome/SessionManager"));
+				session_client_id = session.RegisterClient("Tomboy", startup_id);
+				
+				ClientPrivate client = Bus.Session.GetObject<ClientPrivate>("org.gnome.SessionManager", session_client_id);
+				client.QueryEndSession += OnQueryEndSession;
+				client.EndSession += OnEndSession;
+			}
+			catch (Exception e)
+			{
+				Logger.Debug("Failed to register with session manager: {0}", e.Message);
+			}
 
 			Gtk.Application.Init ();
 			program = new Gnome.Program (display_name,
 			                             Defines.VERSION,
 			                             Gnome.Modules.UI,
 			                             args);
-
-			// Register handler for saving session when logging out of Gnome
-			Gnome.Client client = Gnome.Global.MasterClient ();
-			client.SaveYourself += OnSaveYourself;
 		}
 
 		public void RegisterSessionManagerRestart (string executable_path,
 		                string[] args,
 		                string[] environment)
 		{
-			if (executable_path == null)
-				return;
-
-			// Restart if we are running when the session ends or at crash...
-			Gnome.Client client = Gnome.Global.MasterClient ();
-			client.RestartStyle =
-			        Gnome.RestartStyle.IfRunning | Gnome.RestartStyle.Immediately;
-			client.Die += OnSessionManagerDie;
-
-			foreach (string env in environment) {
-				string [] split = env.Split (new char [] { '=' }, 2);
-				if (split.Length == 2) {
-					client.SetEnvironment (split[0], split[1]);
-				}
-			}
-
-			// Get the args for session restart...
-			string [] restart_args = new string [args.Length + 1];
-			restart_args [0] = executable_path;
-			args.CopyTo (restart_args, 1);
-			client.SetRestartCommand (restart_args.Length, restart_args);
+			// Nothing to do, we dropped the .desktop file in the autostart
+			// folder which should be enough to handle this in Gnome
 		}
 
 		public void RegisterSignalHandlers ()
@@ -125,38 +128,51 @@ namespace Tomboy
 				        Mono.Unix.Native.Stdlib.GetLastError ());
 		}
 
-		private void OnSessionManagerDie (object sender, EventArgs args)
-		{
-			// Don't let the exit signal run, which would cancel
-			// session management.
-			Gtk.Main.Quit ();
-		}
-
-		private void CancelSessionManagerRestart ()
-		{
-			Gnome.Client client = Gnome.Global.MasterClient ();
-			client.RestartStyle = Gnome.RestartStyle.IfRunning;
-			client.Flush ();
-		}
-
 		private void OnExitSignal (int signal)
 		{
-			// Don't auto-restart after exit/kill.
-			CancelSessionManagerRestart ();
-
 			if (ExitingEvent != null)
 				ExitingEvent (null, new EventArgs ());
 
 			if (signal >= 0)
 				System.Environment.Exit (0);
 		}
-
-		private void OnSaveYourself (object sender, Gnome.SaveYourselfArgs args)
+		
+		private void OnQueryEndSession (uint flags)
 		{
-			Logger.Log ("Received request for saving session");
-
+			Logger.Info("Received end session query");
+			
+			// The session might not actually end but it would be nice to start
+			// some cleanup actions like saving notes here
+			
+			// Let the session manager know its OK to continue
+			try{
+				ClientPrivate client = Bus.Session.GetObject<ClientPrivate>("org.gnome.SessionManager", session_client_id);
+				client.EndSessionResponse(true, String.Empty);
+			}
+			catch (Exception e)
+			{
+				Logger.Debug("Failed to respond to session manager: {0}", e.Message);
+			}
+		}
+		
+		private void OnEndSession (uint flags)
+		{
+			Logger.Info("Received end session signal");
+			
 			if (ExitingEvent != null)
 				ExitingEvent (null, new EventArgs ());
+			
+			// Let the session manager know its OK to continue
+			// Ideally we would wait for all the exit events to finish
+			try
+			{
+				ClientPrivate client = Bus.Session.GetObject<ClientPrivate>("org.gnome.SessionManager", session_client_id);
+				client.EndSessionResponse(true, String.Empty);
+			}
+			catch (Exception e)
+			{
+				Logger.Debug("Failed to respond to session manager: {0}", e.Message);
+			}
 		}
 		
 		public void OpenUrl (string url, Gdk.Screen screen)
diff --git a/Tomboy/GnomeSession.cs b/Tomboy/GnomeSession.cs
new file mode 100644
index 0000000..a4dd25f
--- /dev/null
+++ b/Tomboy/GnomeSession.cs
@@ -0,0 +1,47 @@
+
+using System;
+using NDesk.DBus;
+using org.freedesktop.DBus;
+
+/* 
+ * Gnome Session DBus API
+ * http://people.gnome.org/~mccann/gnome-session/docs/gnome-session.html
+ * Here we've defined only what's needed to register and respond to the
+ * SessionManager
+ */
+namespace org.gnome.SessionManager
+{
+	/*
+	 * org.gnome.SessionManager
+	 */
+	[Interface("org.gnome.SessionManager")]
+	public interface SessionManager
+	{
+		void Setenv(string variable, string val);
+		void InitializationError(string message, bool fatal);
+		ObjectPath RegisterClient(string app_id, string client_startup_id);
+		void UnregisterClient(ObjectPath client_id);
+	}
+	
+	/* 
+	 * org.gnome.SessionManager.ClientPrivate
+	 */
+	
+	/* Define callbacks */
+	public delegate void StopCallback();
+	public delegate void QueryEndSessionCallback(uint flags);
+	public delegate void EndSessionCallback(uint flags);
+	public delegate void CancelEndSessionCallback();
+	
+	[Interface("org.gnome.SessionManager.ClientPrivate")]
+	public interface ClientPrivate : Introspectable, Properties
+	{
+		void EndSessionResponse(bool is_ok, string reason);
+		
+		event StopCallback Stop;
+		event EndSessionCallback EndSession;
+		event QueryEndSessionCallback QueryEndSession;
+		event CancelEndSessionCallback CancelEndSession;
+	}
+	
+}
diff --git a/Tomboy/Makefile.am b/Tomboy/Makefile.am
index 0897365..6dae9b9 100644
--- a/Tomboy/Makefile.am
+++ b/Tomboy/Makefile.am
@@ -50,6 +50,7 @@ GNOME_CSFILES =					\
 	$(srcdir)/GConfPreferencesClient.cs	\
 	$(srcdir)/GnomeApplication.cs		\
 	$(srcdir)/GnomeFactory.cs		\
+	$(srcdir)/GnomeSession.cs		\
 	$(srcdir)/XKeybinder.cs			\
 	$(srcdir)/gtk-sharp-beans/*.cs
 
