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](https://unix.stackexchange.com/questions/2745/how-to-run-a-script-during-gnome-log-out) 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](http://www.linuxquestions.org/questions/linux-desktop-74/gnome-run-script-on-logout-724453/#post3560301) suggesting a workaround but, according to the first reply, it does not work if I shutdown the computer instead of only logging off.