0

I know of the Meta+L (and some other combo) to lock the screen which makes the screen go to sleep pretty quickly.

However, I'd like to put my computer screen to sleep but not lock it.

Is there a way to have a hotkey do that under Gnome Ubuntu 18.04?

Alexis Wilke
  • 2,707
  • Sleep 0r screen dark?? When you move the mice.. Screen becomes active.. – PRATAP Mar 15 '20 at 06:04
  • You want to make it sleep with shortcut keys pressed 0r at certain amount 0f time when inactive?? – PRATAP Mar 15 '20 at 06:16
  • https://askubuntu.com/a/1075209/739431 – PRATAP Mar 15 '20 at 06:16
  • @PRATAP, sorry, I went to bed after I posted. The answer below is correct. I want the monitor to go to sleep (dpms off). When I leave the computer, I'd like to put the monitor to sleep "instantly" instead of leaving it sitting for the time out to kick in. For example, when I go to have dinner, I can put the screen to sleep instantly, I won't use the screen for 30 to 60 min. – Alexis Wilke Mar 15 '20 at 16:40

1 Answers1

2

First, in settings - Screen Lock, turn "Screen Lock" off to disable the lock screen from automatically kicking in after a period of inactivity, or when you return from "sleep" state.

To make Super+L blank the screen, first disable its default assignment in "Settings" - "Keyboard shortcuts" (Click the entry, press Backspace to clear the assignment and click "Set" to finish.

Then, under custom shortcuts, create a new shortcut key (click "+" at the bottom). As "Command", specify

sh -c 'sleep 1 && xdg-screensaver activate'

and assign your desired shortcut key.

The "sleep" command is needed to give you time to release the keys. Otherwise, the command is executed, but as you release keys, the screen will be unblanked already.

Update 2023-07-10: the command originally provided, i.e., sh -c 'sleep 1 && xset dpms force off', only works when the traditional display server X11 is in use. Thanks to Martin Laakso for pointing this out,

vanadium
  • 88,010