4

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
8

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:

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 '18 at 6:17
  • @abu_bua I think you need to upload image again ;-) – Kulfy Aug 7 '18 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 '18 at 15:59
  • no lid options exist in my menu. – krivar Jan 1 '20 at 15:08
0

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:

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.