I'm using Ubuntu Mate 16.04. I would like to configure the system so that it reboots or shuts down on logoff. Here's what I have done so far:
I created /etc/lightdm/lightdm.conf.d/50-ubuntu-mate.conf
with the following content.
[Seat:*] user-session=mate session-cleanup-script=/sbin/reboot allow-guest=false
While this successfully reboots the machine on logoff, I have one problem with it. It also reboots the machine when I am at the login greeter and I select a different user account for login. I do not want to reboot when I'm not actually logged into an account and all I am doing is selecting a user from the drop down to login as.
Can anyone tell me if there is another way to go about this that does not cause reboots from the login greeter?
Track whether or not we are coming from a user session
I'm posting an answer to my own question here. If anyone has other solutions, I'd love to see them.
Solution overview
It's not enough to check and see if anyone is logged in when the
session-cleanup-script
runs because, this script runs after users have been completely logged out. I decided to go about tracking this like so.greeter-setup-script
to set a temporary file on loginsession-cleanup-script
, check to see if the file exists.Example configuration
Example
/etc/lightdm/lightdm.conf.d/50-ubuntu-mate.conf
fileExample
greeter-setup.sh
scriptExample
session-cleanup.sh
script