6

I am trying to keep my laptop running with the lid closed.

What I've done so far is:

  1. In the file /etc/systemd/logind.conf add HandleLidSwitch=ignore both for docked and plain mode. This didn't do the trick at all.
  2. In the file /etc/UPower/UPower.conf set IgnoreLid=true

This worked, but now my TeamViewer session closes and the screen is locked, so I still can't actually use the laptop.

1

2 Answers 2

10

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 /org/gnome/settings-daemon/plugins/power/lid-close-ac-action schema as show in the first line of the images shown above, and make your settings:

enter image description here

4
  • Thanks for the clear, well documented, reply. Unfortunately this didn't solve the problem I think the problem is not with the power management but is related to user/log in management killing my session when the lid closes. Or am I looking in the wrong direction?
    – Hades
    Jul 27, 2018 at 6:17
  • @abu_bua I think you need to upload image again ;-)
    – Kulfy
    Aug 7, 2018 at 19:27
  • @Hades, regardless if this solved your problem, abu_bua's answer answered your question. Either accept this and make a new question describing the problem or edit your question.
    – Rakaim
    Nov 20, 2018 at 15:59
  • no lid options exist in my menu.
    – krivar
    Jan 1, 2020 at 15:08
4

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:

4
  • Yes working but when I reopened the laptop it changes the resolution of the screen on the higher one! Jul 20, 2021 at 6:49
  • What do you mean with higher one? Do you use two screens?
    – rubo77
    Jul 20, 2021 at 6:53
  • My actual screen resolution is 1600x900, if I close the laptop when I reopen it I get the login screen at 1920x1080 and once logged Gnome has this resolution. I am using only one screen. Jul 20, 2021 at 8:05
  • As a workaround I would call a script to restore the desired resolution on resume: askubuntu.com/q/204073/34298
    – rubo77
    Jul 20, 2021 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.