Ubuntu – place a logout script for LightDM

lightdm

Previously in Karmic, we created a logout script that does some work in the background on backing up a users home directory, this script was put in the /etc/GDM/PostSession directory.

I can't figure out where to put a script that I want to run during a logout in LightDM.

I've searched and have found many people who are looking for this answer, so any help would be greatly appreciated.

Best Answer

At least since Ubuntu 12.04 there is now an option session-cleanup-script which can be added to the [SeatDefaults] section of /etc/lightdm/lightdm.conf. /usr/share/doc/lightdm/lightdm.conf.gz is the documentation:

# session-cleanup-script = Script to run when quitting a user session (runs as root)

Do not forget chmod +x yourscript to give your script executing permission.

After changing a value in lightdm.conf it takes only effect after lightdm is restarted. You can either reboot or login to a console (Ctrl+Alt+F1) and run sudo restart lightdm.

(Thanks to Krytarik who posted this answer in http://ubuntuforums.org/showthread.php?t=1918649)