2

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.

Kreezxil
  • 128
  • 1
  • 11

2 Answers2

1

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

kanehekili
  • 7,426
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

ptetteh227
  • 2,044