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:
xrandr
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
else:
pass
elif awake == False:
if int(curr_idle) > seconds*1000:
pass
else:
command3 = "xrandr --output "+screen_name+" --brightness 1"
subprocess.call(["/bin/bash", "-c", command3])
awake = True
time.sleep(2)
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
Quite by accident tonight I discovered a "hack". Enter an invalid password at the lock screen and it will stay there and not fade to black.
I'll be using this technique myself from now on until a better answer comes along. The duplicate candidates don't work for me under Ubuntu 16.04 and like yourself it irritates me the screen turns off.
Feb 20 2018 Update - Disable Dimming CLI method
To prevent screen from turning off you need two settings, one under battery power the other when plugged into wall outlet (A/C).
For battery timeout:
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout <time_in_seconds>
For AC timeout:
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout <time_in_seconds>
So for both Battery and A/C set the time to 0 (never).
For Login screen:
gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
Disable dimming screen when idle:
In Unix & Linux someone complained when on battery screen dims every 20 seconds and wants to turn that feature off:
gsettings set org.gnome.settings-daemon.plugins.power idle-dim false
Best Answer
There are two related work around that may give you the desired result.
1: Create a file /etc/polkit-1/localauthority/50-local.d/whatever_name.pkla Copy the below given text in the file and reboot.
Source: How to disable shutdown/reboot from lightdm in 14.04?
Also look for the mentioned uncomfortable comment in the link.
2: Change your lightdm display manager to GDM display manager.
Installation and switching is explained explicitly:
http://www.n00bsonubuntu.net/content/install-gdm-ubuntu-14-04/
After acitivating GDM follow the steps mentioned in the following link:
http://embraceubuntu.com/2006/03/20/disable-shutdown-for-normal-users/