GNOME: disable sleep on lid close

Install GNOME Tweak Tool and go to the Power section. There's an option to disable the automatic suspend on lid close.

Option details

I compared dconf before and after to find the option, but it turns out that's not how it's implemented. Instead, Tweak Tool creates ~/.config/autostart/ignore-lid-switch-tweak.desktop. The autostart is a script which effectively runs systemd-inhibit --what=handle-lid-switch. So we can see the lid close action is handled purely by systemd-logind.

Alternative route

An alternative would be to edit /etc/systemd/logind.conf to include:

HandleLidSwitch=ignore

This would work all the time, not just when your user is logged in.


Unfortunately, the inhibitor routes didn't seem to work as advertised for me on openSUSE Tumbleweed (42.1) using GNOME. But, I had success with Systemd masking:

systemctl mask sleep.target suspend.target

To undo the mask, you can use unmask:

systemctl unmask sleep.target suspend.target

I had solved this issue once before, but apparently recent versions of Fedora (so far from Fedora 28 to 33, inclusive), require two entries now, whereas before only one was required. So:

user$ sudo vi /etc/systemd/logind.conf

HandleLidSwitch=ignore        <---- Set both of these
HandleLidSwitchDocked=ignore  <---- to ignore lid events.

user$ sudo systemctl restart systemd-logind

EDIT: As mentioned by commenters below, you might want to just reboot after making the edits.