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
  • 118

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
  • 6,402
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
  • 1,904
  • Hello, ptetteh227, do we need to do something additional to power off the lid with this approach? – pa4080 Feb 12 '19 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 '19 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 '19 at 12:43
  • I use lubuntu 18.04. – ptetteh227 Feb 17 '19 at 15:31
  • I want it to blank the screen on close, without sleeping nor locking PC. Is that possible? – MahNas92 Mar 16 '20 at 11:09
  • have you tried this. this should prevent the screen from locking as well and in lubuntu or xubuntu setting 'when laptop lid is closed' to switch off display in the power settings. – ptetteh227 Mar 26 '20 at 08:44