Gnome - run script on logout
I'm investigating the migration of a bunch of machines from KDE to GNOME.
I currently have a collection of scripts which run when a user logs out. KDE provides an easy way to run these scripts - stick them in /opt/kde3/shutdown (or equivalent depending on distro). Any scripts in there get run as the user that's logged out. The only suggestion I can find for doing this in GNOME is to put scripts in to /etc/gdm/PostSession. The trouble with that is that the scripts then run as root. Some of the scripts I need to run manipulate stuff in a the user's home directory which is mounted from a remote server and of course root doesn't have the ability to mess with stuff in such home directories. So a script which runs as root is at best annoying and at worse useless for my purposes. I might be able to do something in the script like Code:
su - $USER -c "some commands" Is there any sensible, easy method to make GNOME run a script when a user logs out with the permissions of that user? |
You could do something like this (from http://ubuntuforums.org/showthread.php?t=252935) in /etc/gdm/PostSession/Default:
logoutscript="$HOME/.gdmlogout"; if [ -x "$logoutscript" ] ; then su $USER -c "$logoutscript" fi which is very similar to what you are thinking. This has the advantage of letting users define their own actions as well. |
I've tried running a script under su and it does work as expected so looks like I'll be using that method.
Giving the user the ability to define the logout script is not what I was after but maybe I'll do that as well as the scripts they can't define. It seems like a rather large omission that GNOME doesn't provide a neater method of defining logout scripts. cheers. |
I've had a similar problem. I needed to run a command before gnome exits (and not after). I wrote a small python script to listen to the gnome 'save-yourself' event' and then run my command.
Hopefully somebody might find this useful. Code:
#!/usr/bin/env python |
Well I finally got around to trying that Python script. Whilst it does exactly what it says and is very cunning, like the GDM PostSession script is doesn't get called if the user ends the GNOME session by way of rebooting or shuting down the machine. It has the advantage over using GDM scripts that you can run something as the user that's logging out without having to use su though. What I really need now is some way getting a script to run if the user exits GNOME by way or restart or shut down.
|
All times are GMT -5. The time now is 03:14 PM. |