3

I want to prevent my system (Ubuntu 22.04 on old HP laptop) from sleeping when closing the lid.

I already tried to edit my /etc/systemd/logind.conf :

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
HandleLidSwitch=ignore                 #
HandleLidSwitchExternalPower=ignore    #
HandleLidSwitchDocked=ignore           #
#HandleRebootKey=reboot
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
LidSwitchIgnoreInhibited=no            #
#RebootKeyIgnoreInhibited=no
#HoldoffTimeoutSec=30s
IdleAction=ignore                      #
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RuntimeDirectoryInodesMax=400k
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192

Before editing, my system slept as soon as the lid was closed; but now it takes a while before sleeping. The odd thing is that when the lid isn't closed, the system stays awake as long as I want it to.

I don't know if any logs are going to be useful; or what the cause may be.

$ gsettings get org.gnome.settings-daemon.plugins.power lid-close-ac-action
suspend

And

$ gsettings get org.gnome.settings-daemon.plugins.power lid-close-battery-action
suspend
2
  • Possible duplicate. Did you already try Gnome Tweaks > General > Suspend when laptop lid is closed? What's the output of: gsettings get org.gnome.settings-daemon.plugins.power lid-close-ac-action and gsettings get org.gnome.settings-daemon.plugins.power lid-close-battery-action? Aug 6, 2022 at 3:06
  • Thanks for answering. I did already edit Gnome tweaks. I edited the main post Aug 6, 2022 at 3:14

2 Answers 2

4

The accepted answer did not work in my case (also on Ubuntu 22.04). I had to install GNOME Tweaks, which is available on the universe repository:

sudo apt update
sudo add-apt-repository universe
sudo apt install gnome-tweaks

and disable Suspend when laptop lid is closed.

1
  • This only prevents suspend when I'm logged in. My laptop still goes to sleep if I close lid on the login page. May 18 at 10:46
2

In order to make the laptop keep on running after closing the lid run these following commands on the Terminal,

While on AC;

gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action 'nothing'

While on Battery;

gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action 'nothing'
2
  • 1
    Thank You guys, this seem to have worked Aug 7, 2022 at 0:23
  • 2
    This simply doesn't work on Ubuntu 22.04. May 18 at 10:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .