61

Since my monitor takes an awful lot of time to turn back on after being physically turned off, I'm looking for a command or a simple utility to turn off my screen with a shortcut. Setting a black screensaver is not satisfactory; I want the screen to "hibernate" (the same effect I would get by turning off the computer while leaving the screen physically on).

The same question for Windows: How can I make my screen blank by a shortcut?

1
  • Press STRG a than k and than y
    – Daniel
    Jan 4, 2012 at 21:25

6 Answers 6

81

Try using

xset dpms force off

to force the screen to turn off.

3
  • 4
    That's really great. For the OP though, when a key is pressed, it turns the screen back on. I'm not sure if that's desirable.
    – Brigand
    Jan 4, 2012 at 21:18
  • 17
    Sometimes works better if you do sleep 1 ; xset dpms force off otherwise remnants of the last keyboard activity (I guess) sometimes turns the screen back on immediately.
    – Mat
    Jan 4, 2012 at 21:19
  • 1
    This is exactly what I've been looking for. Thanks @siva-charan. The only thing I was wondering is how I could ask for a password when I wake the screen. I'm basically using a shortcut to turn off my screen and I would like it to ask for password on wake.
    – Isabel Inc
    Feb 6, 2017 at 0:07
29

I made a file called /home/me/bin/blank and made it executable chmod +x blank with the following in it:

#!/bin/bash
sleep 1; xset dpms force off

Then I set a shortcut in Gnome3 application "keyboard" (gnome-control-center keyboard) to run that script when I push CTRL+ALT+Q.

Man I love linux.

5
  • 1
    I liked this :) Just as a little addendum, take a look at systembash.com/… to see how you could set up a timed use of this trick and turn your monitor on/off at specified time
    – danicotra
    Jun 25, 2017 at 11:01
  • you mean turning your monitor on at a specified time with cron?
    – frankster
    Feb 2, 2018 at 17:20
  • How do u turn them back on? lol Mar 11, 2021 at 0:24
  • @JamieHutber just press a key or move the mouse to turn the screen on again. Aug 8, 2021 at 9:05
  • 2
    I created a launcher icon on my taskbar that runs the following command: bash -c "sleep 1; xset dpms force off" Aug 8, 2021 at 9:07
4

I use Alex Cabal script to turn my two monitors screens off and on and it works very fine for me.

#!/bin/bash

# turn screens off/on
# (ɔ) alex cabal

screenOffLockFile=/tmp/screen-off-lock

if [ -f $screenOffLockFile ];
then
    rm $screenOffLockFile
    notify-send "Screen on." -i /usr/share/icons/gnome/48x48/devices/display.png
else
    touch $screenOffLockFile
    sleep .5
    while [ -f  $screenOffLockFile ]
    do
        xset dpms force off
        sleep 2
    done
    xset dpms force on
fi
3
  • Generally, answers are much more helpful if they include an explanation of what the code is intended to do, and why that solves the problem without introducing others.
    – MMM
    Dec 18, 2019 at 12:40
  • 2
    @MMM By clicking on the provided link, any interested user can go to a page of the original author of the script that explains in detail how it works.
    – Tropilio
    Feb 3, 2020 at 16:51
  • Ideally answers are self contained so everything is still here if a linked site disappears. Dec 22, 2021 at 15:38
3

As a premise, I personally prefer hamstar/Siva Charan solution. Anyway, I know another possible way could be a script that sets screensaver to blank and then make it start:

rem #!/bin/bash

xset s blank ; sleep 1 ; xset s activate

So as just not to let unspoken things

1
3

You can go to your distro's settings, and add a shortcut => putting the command - xset dpms force off, then put a hotkey(say F9). That's it, whenever you hit the hotkey, your monitor's screen will turn off

6
  • Welcome to Super User! Please don't post irrelevant answers to questions
    – Virtuality
    Jun 17, 2020 at 9:00
  • Is this irrelevant? If yes, how?
    – tavish
    Jun 17, 2020 at 11:41
  • You describe how to perform this action in Ubuntu. The author requests a solution to this for Linux.
    – Virtuality
    Jun 17, 2020 at 11:59
  • thank you, I have edited my answer and it should work with most Linux distro's (especially if you use use gnome-shell).
    – tavish
    Jun 19, 2020 at 8:19
  • Perfect, good to know.
    – Virtuality
    Jun 19, 2020 at 10:02
2

slock locks the screen gracefully.

2
  • I just installed it and screen totally locked without turning LED off! and seems there isn't any way to unlock screen again :|
    – Morteza
    Nov 28, 2015 at 14:29
  • 2
    @MortezaZiaeemehr It's very minimal. Just enter your password and press Enter. Dec 17, 2015 at 1:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.