When I shut down my computer I want to show some pending tasks that I have to do before leaving the office... I did a local application to manage those tasks, basically I just want to run a command, and shut down after I kill the app executed.
You can do this by creating a script in /etc/rc0.d (for shutdown) and /etc/rc6.d (for reboot). To do this, run:
gksu gedit /etc/rc0.d/K01mycustomscript
Edit your shutdown script in the text editor then run:
sudo chmod +x /etc/rc0.d/K01mycustomscript
And if you want it to run on reboot also then run this:
sudo cp /etc/rc0.d/K01mycustomscript /etc/rc6.d/K01mycustomscript
Source: this forum thread
Sounds like a question for superuser.com to me. Anyway, after some Googling I found How to run a script on logout? which says to add the script to $HOME/.bash_logout.
If that doesn't work, add
to /etc/gdm/PostSession/Default so it executes the logout script properly.
Seeing as before shutdown the user is logged off anyway, this should cover both bases.