2

In Ubuntu 12.04 I used LightDM config parameter session-cleanup-script to run a script when a user logs out.

In Ubuntu 16.04 this script is also fired when a user types the wrong username or password. So the user wasn't even logged in.

How can I run a script in Ubuntu 16.04 only if a user logs out?

EDIT:

OK, I thought this is an easy one. But it seems to be more complex. I use this on public terminal PCs. At first LightDM is not loaded. The user has to choose between Windows (via VMware View), Ubuntu and a Kiosk browser. He clicks a specific button to login to Ubuntu. Now LightDM (and some other stuff) gets started. When the user logs out LightDM gets stopped from the script in session-cleanup-script.

I think the Upstart/systemd method wont work as I need some environment variables like $USER and $HOME, right?.

The DBus signal seems to fire when the user wants to logout. I need a event when the user already is logged out to clean some things.

Michael
  • 361
  • 1
  • 4
  • 15
  • [This question](http://askubuntu.com/q/517633/602680) and its answer could be useful. – TheOdd Nov 15 '16 at 15:57
  • @OwenHines: Upstart is pretty much dead (or at least very much legacy and deprecated) in Xenial. – David Foerster Nov 15 '16 at 16:16
  • @DavidFoerster Oh, sorry. Good to know. – TheOdd Nov 15 '16 at 16:17
  • A good way to do it using systemd instead of lightdm is outlined in this perma-linked comment: http://askubuntu.com/a/796157/610274 – Warley Nov 15 '16 at 16:40
  • Thanks for your comments and great hints. I've added more details to my question. Thought it would be easier. – Michael Nov 16 '16 at 07:07
  • If the script doesn't need to run long time, you could use session inhibitors, see my answer here : http://askubuntu.com/q/828524/295286 – Sergiy Kolodyazhnyy Nov 16 '16 at 07:24
  • ` I need a event when the user already is logged out` , well put a delay with `sleep` , or fire up a script that will keep looking at output of `who` command to see when username disappears form the list of logged in users. – Sergiy Kolodyazhnyy Nov 16 '16 at 07:40
  • I also tried pam-script now. But when *ses_close is called for Unity session the username is lightdm and not the real user which was logged in. – Michael Nov 16 '16 at 09:11

0 Answers0