Keep a laptop running with closed lid
I am trying to keep my laptop running with the lid closed.
What I've done so far is:
- In the file
/etc/systemd/logind.conf
addHandleLidSwitch=ignore
both for docked and plain mode. This didn't do the trick at all. - In the file
/etc/UPower/UPower.conf
setIgnoreLid=true
This worked, but now my TeamViewer session closes and the screen is locked, so I still can't actually use the laptop.
Command line based
There are some gsettings you can use:
-
Handling when on ac line
gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action 'nothing'
This will disable any action when the lid gets closed, and the laptop is plugged into AC.
To undo simply:gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action 'suspend'
Possible setting values instead of suspend are:
'blank', 'suspend', 'shutdown','hibernate', 'interactive', 'nothing', 'logout'
-
Handling when on battery
gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action 'nothing'
-
Handling when an external monitor is plugged in
gsettings set org.gnome.settings-daemon.plugins.power lid-close-suspend-with-external-monitor 'nothing'
Using a gui
If you prefer a gui based solution, you have to install
sudo apt install dconf-editor
Invoke with
dconf-editor&
or by searching the program dash.
Go to the schema as show in the first line of the images shown above, and make your settings:
On Ubuntu 19.10 the gsettings set org.gnome.settings-daemon.plugins.power lid-close-*
actions don't seem to work any more.
Keep on running on lid-close instead of suspend
Edit the file /etc/systemd/logind.conf
with sudo
and change the line
#HandleLidSwitch=.....
to
HandleLidSwitch=lock
And reboot your system.
The file /etc/systemd/logind.conf
controls how logind shall handle the system power and sleep keys and the lid switch to trigger actions such as system power-off or suspend. Can be one of
"ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate", and "lock". for these settings:
HandlePowerKey=, HandleSuspendKey=, HandleHibernateKey=, HandleLidSwitch=,
HandleLidSwitchExternalPower=, HandleLidSwitchDocked=
Reference:
- http://tipsonubuntu.com/2018/04/28/change-lid-close-action-ubuntu-18-04-lts/
- http://manpages.ubuntu.com/manpages/eoan/man5/logind.conf.5.html