1

I want to use a keyboard short cut to manually turn the screen off.

This answer reduces the brightness but doesn't turn the screen off.

This answer does what I want if launched from the terminal, but when used as a keyboard short-cut, the screen off only lasts 1 second (and the screen comes on after one second). The same problem occurs with xset dpms force standby.

For some reason, I can't get This answer to work (it just doesn't do anything).

(the computer is a laptop and I want the monitor to come back alive if either the mouse is moved or any key pressed, as in This answer).

user2413
  • 14,337

1 Answers1

1

I suspect the screen comes back on is because you've just fired a keyboard event. It works on my computer but that could be explained by event timing, bus types, who knows.

Anyway, try giving it a bit of lead time for any X events to seep away:

sleep 1 && xset dpms force standby
Oli
  • 293,335
  • When I put this in the command field (of the create shortcut) menu, press my keyboardshortcut and wait (more than 1 sec), nothing happens~ I know it's dicey but would you have any idea? – user2413 Mar 31 '16 at 10:59
  • 1
    In some circumstances, you may need to wrap it in something that makes it a single command, ie: sh -c "sleep 1 && xset dpms force standby" – Oli Mar 31 '16 at 11:00
  • Perfect, that second one works magic! – user2413 Mar 31 '16 at 11:01