Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to run a script before I log out of my GNOME session, to warn myself if I have forgotten a pendrive plugged into the machine.

However, all solutions I have found have not been enough for me:

  • This similar question suggests editing the /etc/gdm/PostSession/Default file, but I don't have the permissions to do that. (And the file is currently empty on my machine, so there are no existing hooks to take advantage off)

  • I also found this post suggesting a workaround but, according to the first reply, it does not work if I shutdown the computer instead of only logging off.

share|improve this question

2 Answers

If you want your session to block under all circumstances you need root-privileges. There's no way around that. User root can always kill -9 your processes. I am surprised that a shutdown does not make gnome emit the "save-yourself" signal. Also I believe the "PostSession" scripts are only run after gnome-session has terminated and (I believe) just before the Xserver terminates, meaning that's not the place where you would want to put a warning that's supposed to show up on screen (if I'm correct).

What may work is a Gnome application that a) reacts on the "save-yourself" gnome event AND b) reacts on SIGTERM in the same way it reacts to "safe-yourself". Beyond that there's little you can do, especially without root privileges.

However you can solve the non-root problem: Write a PostSession script that does what you want and suggest to somebody with root-privileges to deploy it on all machines as it is a sensible tool that helps users a lot. Usually the guys with root-privileges are paid to make/keep users happy. :-)

What's the problem you are trying to solve? Why may you not logout of your session when a pendrive is plugged in?

You can have a dbus client that displays "Don't forget to unplug the device!" when gvfs announces unmounting a Filesystem on a USB device. But I don't know how well that works or even serves your purposes.

share|improve this answer
This is for my account at the computer lab; If I forget my pendrive plugged in when I logout I can leave it behing when I go home. This is also why I don't have root priviledges (and unfortunatly asking anything for the admins here is a very bureocratic process). What would I have to do to make a dbus client like you said? I never worked with something like this and I can't find any documentationon telling what messages gcfs supports when I search for it. – missingno Sep 28 '12 at 14:19
up vote 0 down vote accepted

I finally managed to actually test the Python script I mentioned as the second option in my question. It turns out that it does work when asking to shut down as well, not just on reboot.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.