The Computer Oracle

How to turn off screen with shortcut in Linux?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Darkness Approaches Looping

--

Chapters
00:00 How To Turn Off Screen With Shortcut In Linux?
00:35 Accepted Answer Score 87
00:50 Answer 2 Score 31
01:18 Answer 3 Score 4
01:46 Answer 4 Score 4
02:11 Answer 5 Score 3
02:35 Thank you

--

Full question
https://superuser.com/questions/374637/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #keyboardshortcuts #blankscreen

#avk47



ACCEPTED ANSWER

Score 87


Try using

xset dpms force off

to force the screen to turn off.




ANSWER 2

Score 31


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.




ANSWER 3

Score 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



ANSWER 4

Score 4


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




ANSWER 5

Score 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