Due to a recent bug, each time my screen turns off, I cannot get it back on.

Currently, the screen starts turning off after the computer is locked - which effectively means that I cannot lock my computer without having to completely restart it.

Is there a way to lock it, but without the monitor going to sleep/off?


2 Answers 2


If you need or want a solution that prevents the screen to fall asleep, but that does dim/lock the screen after a while, there is another solution: instead of the system's own dim/lock option, use the script below to run in the background. You will need to install xprintidle.

How to set up:

  • Disable all dim / lock options in System Settings. (In Brightness & lock AND in "Energy" settings)

  • install xprintidle:

    sudo apt-get install xprintidle
  • Find your screen name; run in a terminal:


    Look for the name in the line where it says "connected". Your screen name could be for example VGA-1 or DVI-I-1.

  • Copy the script below, set the correct screen_name, the idle time before it should lock/dim the screen, and paste it into an empty file. Save it aslock_dim.py

The script

#!/usr/bin/env python3

import subprocess
import time

seconds = 600 # number of seconds to wait before lock/dim the screen
screen_name = "DVI-I-1" # example, replace it with your screen's name

awake = True

while True:
    curr_idle = subprocess.check_output(["xprintidle"]).decode("utf-8").strip()
    if awake == True:
        if int(curr_idle) > seconds*1000:
            command1 = "gnome-screensaver-command -l"
            command2 = "xrandr --output "+screen_name+" --brightness 0.1"
            subprocess.call(["/bin/bash", "-c", command1])
            subprocess.call(["/bin/bash", "-c", command2])
            awake = False
    elif awake == False:
        if int(curr_idle) > seconds*1000:
            command3 = "xrandr --output "+screen_name+" --brightness 1"
            subprocess.call(["/bin/bash", "-c", command3])
            awake = True

Test the script by opening a terminal and type:

python3 /path/to/lock_dim.py

If it works as you like, add it to your startup applications: Open Dash > "Startup Applications" > "Add", add the command:

python3 /path/to/lock_dim.py
  • unfortunately the command gnome-screensaver-command -l just turns the screen blank, showing the lock screen only for a second. How can I just get the lock screen? The huge nice clock.
    – Sadık
    Jul 21, 2017 at 11:17

Go to System preferences > Brightness & lock, then change "Turn Screen off when inactive" to Never.

Now click on setting icon from top right click on you account username your screen will be locked and never sleep.

  • Actually it still starts fading the second I lock it, either by clicking Lock in the user menu, or using the keyboard shortcut.
    – jcora
    Sep 23, 2014 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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