1

I have XUbuntu 18.04.

I want to close the lid on my laptop and have the screen immediately go blank (black) or off, but the computer itself to remain awake (active [not suspended]).

I've installed gnome-tweaks and that allowed me to disable the suspension feature, but it also disables the screen blanking.

logind.conf doesn't have a setting for this and gnome-tweaks and xfce-power both seem to override it regardless.

In regards to @ptetteh227, this file is entirely commented out. I've looked at the man page for it and there are no settings one can make to achieve the action that I need. https://pastebin.com/MXKnikKn

Have considered allowing it go to a lock screen but seems like another question to me.

  • Kindly post the content of /etc/systemd/logind.conf – ptetteh227 Feb 9 at 21:45
  • I added it above to the opening question. – Kreezxil Feb 11 at 13:04
2

open a terminal and type:

xset dpms force off

as soon as you mouse moves or you press a button, the monitor will come alive again. If you would like to run that code whenever you close the lid, you'll have to some more work: Add to following line into /etc/acpi/events/lid:

event=button/lid
action=/etc/acpi/actions/handleLidClose.sh %e

Now create the file: /etc/acpi/actions/handleLidClose.sh and paste the code

#!/bin/bash
echo "$1" | grep -q open /proc/acpi/button/lid/LID0/state && exit 0
xset dpms force off

into it.

You can name the file any way you want, but dont forget to make it executable:

chmod +x /etc/acpi/actions/handleLidClose.sh

All commands must be excecuted as sudo or su

1

To prevent the machine from suspending when lid is closed. sudo nano /etc/systemd/logind.conf

and uncomment the parameter below

...
HandleLidSwitch=ignore
...

now restart systemd daemon:

sudo service systemd-logind restart

this works on the fly without need to do a reboot to revert back to the default suspending when lid close,d just comment that line like before

  • Hello, ptetteh227, do we need to do something additional to power off the lid with this approach? – pa4080 Feb 12 at 18:31
  • 1
    I didn't have to do anything additional as my laptops screen goes off automatically when i close the lid. haven't tried on another laptop though – ptetteh227 Feb 12 at 20:02
  • @ptetteh227 my screen doesn't automatically turn off when i close the lid. Which desktop are you using? maybe that holds part of the solution. – Kreezxil Feb 14 at 12:43
  • I use lubuntu 18.04. – ptetteh227 Feb 17 at 15:31

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.