Shell – Execute script prior to cinnamon logout (unsing MDM or other display manager)

cinnamonlogoutmdmsessionshell-script

I'm using cinnamon as desktop environment on my Linux Mint system.

I want to automate a backup using unison:

Unison shall be executed prior to each logout off my session. So I was looking for a solution to execute unison every time I use the shutdown button from the cinnamon menu.

However, I was not able to find a hook that allows me to intercept the shutdown.

I also read about session-cleanup-script in /etc/lightdm/lightdm.conf. However, this does not seem to apply to my system: I seem to use the MDM Display Manager. I've been looking for hooks there.

I also tried to override /usr/bin/cinnamon-session-quit, but this seems not to be called from the shutdown menu.

Best Answer

If you switch to LightDM as I was suggesting, then it should be simple.

Set the following parameter in the config file:

/etc/lightdm/lightdm.conf
session-cleanup-script = Script to run when quitting a user session (runs as root)
Related Question