Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Which would be the best way to run a script upon GUI logoff, shutdown, hibernate, sleep modes? In 12.04 I think I did this in /etc/lightdm/lightdm.conf, but on 13.10, the folder structure changed and when I create this script, The display manager wont even start upon boot.

I am looking to implement a simple automatic truecrypt unmount command

truecrypt -d

but of course this would go for any script.

Edit: The file doesn't exist, and if I create it and just put the lines

session-cleanup-script = /path/to/executable/

, After reboot I can't log in anymore until I delete the file anymore. This also happens if The File starts with

session-cleanup-script = ... 

How come this is not working at all, and/or why the file doesnt exist in the first place? thanks

share|improve this question
up vote 1 down vote accepted

That file, /etc/lightdm/lightdm.conf, should look like:


Try also in terminal to see what is happening when you assign a value to a variable like this: a = b and when you assign a value to a variable like this: a=b. First variant will give you all the time a command not found error. So, please, don't put spaces around the = in assignments!

share|improve this answer
Ok, thanks, that worked. Apart from the space in the assignment, the main problem in the end was that I got over-eager and added a session-setup-script at the same time, which contained a non-accepted command (truecrypt scripted mount), and then I couldnt even log in with the lightdm.conf in place. Am I right to assume that reboot and shutdown also log out the user? – TNT Nov 13 '13 at 7:58
A normal (not forced) reboot/shutdown, yes, imply a successful log out of all currently logged users. – Radu Rădeanu Nov 13 '13 at 8:47

Your Answer


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.