Ubuntu Desktop - Auto power off when laptop lid is closed

There’s only “Suspend” and “Do nothing” options for laptop close actions.

To have Ubuntu shutdown when the laptop lid is closed, edit the logind.conf file:

sudo vi /etc/systemd/logind.conf

Uncomment the line #HandleLidSwitch=suspend and change it to HandleLidSwitch=poweroff.

You can also change the value to HandleLidSwitch=hibernate to hibernate Ubuntu when lid is closed.

Restart the machine or issue the following command to apply the change:

sudo systemctl restart systemd-logind.service