Pages

September 25, 2009

Running commands on GNOME logout

This post deals with GNOME, which disqualifies it from any reasonable "light-and-lean" discussion, but I don't exactly know where else to make a note of this.

One of the bigger omissions from GNOME is that there is no built-in mechanism for executing commands at logout. I discovered this the hard way when trying to set up MPD to run completely in userspace (to be documented in an upcoming post). However, it is possible to make GDM run arbitrary stuff at the end of the session, and that can be used to good effect as described here. In the event that that link goes bad, in summary what you do is edit /etc/gdm/PostSession/Default
and add
logoutscript="$HOME/.gdmlogout";
if [ -x "$logoutscript" ] ; then
su $USER -c "$logoutscript"
fi
to the file. Then create a file .gdmlogout in your home directory and make it executable.

You need to note that this will only work if you are using GDM and the .gdmlogout file will execute no matter what desktop environment you log into.

No comments: