How to turn off screen with shortcut in Linux?

Solution 1:

Try using

xset dpms force off

to force the screen to turn off.

Solution 2:

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.

Solution 3:

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

Solution 4:

slock locks the screen gracefully.