Making something happen at logout

###My brain hurts.

I’ve been screwing around trying to improve how my system handles login and logout tasks with no success whatsoever, so I give up; How can I do it?

I also want users to be able to edit this script easily so some way to have a script execute from ~ would be ideal.

Do you want to create a script to be manually executed like for example:

espeak goodbye
mate-session-save --logout

Or do you want to change permanently what the system does every time you logout (that would be awesome!)?

1 Like

Permanently modify what the system does, and make it per-user so users can add their own logout (and maybe even login) scripts via some tweaks to some files in home.

There is so much conflicting information, but I think pam is a good first thing to try out. I’ve attempted to make something happen with pam by adding my script in /etc/pam.d and doing chmod a+x to make it usable but no joy came from that, not even when I try tor use pam_exec.so to run the thing I want. (I even tried commands directly rather than shell files, not sure if that’s kosher.)

At this point? I’m like Whatever works, yo.

Never knew about espeak. Hurray, a new thing for me to play with! :slight_smile:

1 Like

I took some info from "Adding System Hooks" section here: https://wiki.ubuntu.com/LightDM and I managed to do something similar by adding the line:

session-cleanup-script= sh -c "espeak goodbye"

at my /etc/lightdm/lightdm.conf file. I don't know but, is it possible to make different lightdm configurations per user? Also, according to the link above, session-cleanup-script is executed after user's session ends, so possible it may cause problems if you try to modify user's files in the executed script.

EDIT: You need to restart lightdm to take effect (sudo systemctl restart lightdm).

Is that it? Because when I had that in my lightdm.conf file I ended up stuck at the splash screen; Nothing else would happen!

Anything else I need to do so that my script doesn’t make my system die?

Well I just discovered these stuff, I have no idea. If you can please share the script you use and I will take a look and if I can understand any of it, I may give some ideas (4 eyes are always better than 2 :stuck_out_tongue:) .

Apparently this doesn’t work good, because in my example, even if you just select another user at the lightdm greeter (after you logout) then espeak gets activated again. I think the answer lies at systemd. Can you take a look here: http://askubuntu.com/questions/293312/execute-a-script-upon-logout-reboot-shutdown-in-ubuntu at “HOW TO DO IT WITH SYSTEMD” answer?