Thursday, February 23, 2012

Running a script when logging out of gnome.

Take a look at /etc/gdm/. You will find there a bunch of directories, especially those named PostLogin, PostSession and PreSession. You don't have to be a rocket scientist to figure out what they are for :)
Inside you will find file called "Default". Adding a path to your script will do (eg. /home/user/script/ Just remember that it will affect all users and a scipt will run as root.
If you want something a bit more sophisticated you can add this.
if [ -x "$logoutscript" ] ; then
su $USER -c "$logoutscript"
(I've found it on some linux related forum. Cant't locate it right now)
It will still affect all users, but will not run as root, and only if the script file really exists.

No comments: