From: Mark Wooding Date: Thu, 2 Jun 2011 15:00:20 +0000 (+0100) Subject: dot/xinitrc: Shut down the Gnome session properly on exit. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/8ca91005bcad285426003ddbd2c3f1553ab21b90 dot/xinitrc: Shut down the Gnome session properly on exit. This seems kinder to the various random Gnomey bits of desktop. I was hoping that it would persuade Tracker to leave its databases in a good state, but that doesn't seem to happen. Oh, well. --- diff --git a/dot/xinitrc b/dot/xinitrc index 9c158bb..4f69187 100755 --- a/dot/xinitrc +++ b/dot/xinitrc @@ -326,6 +326,28 @@ EOF done } +###-------------------------------------------------------------------------- +### Gnome session care and feeding. + +session-running-p () { + dbus-send --session --print-reply --dest=org.freedesktop.DBus / \ + org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager \ + >/dev/null 2>&1 +} + +kill-gnome-session () { + if session-running-p; then + info "killing Gnome session manager" + dbus-send --session \ + --dest=org.gnome.SessionManager /org/gnome/SessionManager \ + org.gnome.SessionManager.Logout uint32:2 + for i in 1 2 3 4 5; do + sleep 1 + if ! session-running-p; then break; fi + done + fi +} + ###-------------------------------------------------------------------------- ### Actually start things up. @@ -350,6 +372,7 @@ esac case "$wait" in yes) xwait + kill-gnome-session ;; no) info "not waiting before exit"