How do I turn off screen (backlight included) instead of screensaver

Can you please tell me or point me to a resource that shows me how to turn off the screen totally (not blank out with black color) of my laptop.
Every freaking result I get from google are the opposite of what I want, they are showing how to stop the screen from blanking or showing screensaver at all (or even from locking automatically)

Currently it activates the screensaver when I lock my screen (CTRL+ALT+L) or it is locked automatically.
I want it to turn off the screen completely (backlight included) after it is locked (manually or automatically) since it is a laptop and LCD’s don’t even need screensavers

Screensavers are good for those who want them but there should be an option to completely blank (backlight included) the screen for those who don’t want them.

I always first search google and find results but this time google really missed what I want.

I would be forever grateful if you could help me.

1 Like

Hello, I found the answer by the help of a fellow community member on the #ubuntu-mate IRC channel

The screen timeout can be changed by using xset dpms 1800 which means turn off screen after 30 minutes (1800 are seconds)
Add this command to the list of startup applications so it persists after reboot sleep 10; xset dpms 1800

If you want to turn off the screen after you press CTRL + ALT + L, add a new keyboard shortcut with this command bash lock.sh (code below)

Basically the script locks the screen, sets the screen timeout to 5 seconds (to turn it off again fast if you accidentally move your mouse), wait for a login dbus event and when the user logs in it sets the screen timeout to 30 minutes

#!/bin/bash

# Only works with bash since dash does not support "< <"

# Configuration
LOCKED_TIMEOUT=5  # Screen timeout in seconds when account is locked
UNLOCKED_TIMEOUT=30 # Screen timeout in minutes when account is not locked

# Lock screen
if hash gnome-screensaver-command 2>/dev/null; then
    echo "Using gnome-screensaver-command"
    gnome-screensaver-command -l
elif hash mate-screensaver-command 2>/dev/null; then
    echo "Using mate-screensaver-command"
    mate-screensaver-command -l
else
    echo "No screensaver or lock screen command found"
    exit 0;
fi


# Set screen timeout to 5 seconds
xset dpms $LOCKED_TIMEOUT

# Wait for login to restore dpms
while read -r x; do
case "$x" in 
  *"boolean true"*)
    echo SCREEN_LOCKED
  ;;
  *"boolean false"*)
    echo SCREEN_UNLOCKED
    xset dpms $((UNLOCKED_TIMEOUT*60))
    exit 0
  ;;
esac
done < <(dbus-monitor --session "type='signal',interface='org.mate.ScreenSaver'")
  
  


exit 0


# Ubuntu Gnome
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'"

# Ubuntu Unity
dbus-monitor --session "type=signal,interface=com.canonical.Unity.Session,member=Unlocked"

# Ubuntu Mate
dbus-monitor --session "type='signal',interface='org.mate.ScreenSaver'"
2 Likes

Can someone update the script? I get an error when I use the shortcut: "Error while trying to run /usr/bin/lock.sh) which is linked to the key(l)"
Also, maybe in the next versions turning the screen of while the pc is locked will be the default option. What's the point to waste energy by keeping the screen on while you can't use the pc because it's locked?

Forgot to make the script executable. It works now. Still, this should be the default option when you lock the screen.

This is just the piece of the puzzle I was missing. Made a minor tweak to the script for my machine so it would apply when locking from the menu or hot-key (see below if interested), Someone who knows their way around systemd could probably make it launch at startup, but for me, I just kick it off in a seldom used tmux window after login on. Way better than running sleep 5 ; xset dmps force off before hitting Windos + L to lock the PC.

#!/bin/bash

# Configuration
LOCKED_TIMEOUT=5    # Screen timeout in seconds when account is locked
UNLOCKED_TIMEOUT=30 # Screen timeout in minutes when account is not locked
UNLOCKED_TIMEOUT_SECONDS=$((UNLOCKED_TIMEOUT*60))

# Lock screen
if hash gnome-screensaver-command 2>/dev/null; then
    echo "Using gnome-screensaver-command"
    #gnome-screensaver-command -l
elif hash mate-screensaver-command 2>/dev/null; then
    echo "Using mate-screensaver-command"
    #mate-screensaver-command -l
else
    echo "No screensaver or lock screen command found"
    exit 0;
fi


# Wait for login to restore dpms
while read -r x; do
case "$x" in 
  *"boolean true"*)
    echo SCREEN_LOCKED
    # Set screen timeout to 5 seconds
    xset dpms $LOCKED_TIMEOUT $((LOCKED_TIMEOUT+4)) $((LOCKED_TIMEOUT+8))
  ;;
  *"boolean false"*)
    echo SCREEN_UNLOCKED
    xset dpms $UNLOCKED_TIMEOUT_SECONDS $((UNLOCKED_TIMEOUT_SECONDS+4)) $((UNLOCKED_TIMEOUT_SECONDS+8))
  ;;
esac
done < <(dbus-monitor --session "type='signal',interface='org.mate.ScreenSaver'")

exit 0
3 Likes

Hi, @benjaminhdavis8 and welcome to the Ubuntu MATE Community!