65

We intend to use a RPi at work to drive a status display panel - it will show our project's bug status and a few other statistics of vital importance.

I've been trying stop the screen-saver from blanking the screen with no luck. I've used the following formulas:

I can get Chromium auto-starting in Kiosk mode (I used an item in .config/autostart), but I cannot stop the screen-blanking. X-Windows does not seem to be responding to the .xinitrc file. I tried editing this file on the default user (pi) and also root. Nothing seems to make a difference to the screen saver.

Has anybody managed to stop screen-blanking on Raspbian? Is there a UI option or even a configuration file which will allow me to permanently change the screensaver time out?

I expect that some of these guides might have been tested on other RPi operating systems. Could it be that using the newer Raspbian I need to adopt a different approach to preventing screen blanking?

UPDATE 0: The xset command is able to stop screen blanking when entered directly (via sudo) from the xterm. It does not work when run from the .xinitrc file. Given that the machine auto-logs in as user "pi", how can I ensure that these commands are executed as root every time xwindows fires up.

This machine must be able to run unattended as a sort of kiosk. Once it's in place (it will be a wall-mounted display with no keyboard or mouse permanently attached) the only way we will be able to configure it is via ssh.

5
  • 1
    You should try running the three commands given (xset s off; xset -dpms; xset s noblank) from a terminal started in the X-Windows session. If the screen still blanks, your issue is that the commands are not enough to stop the screen from blanking. If the screen does not blank, then your issue is simply getting those commands executed properly in your X-window session.
    – Nakedible
    Commented Oct 1, 2012 at 13:04
  • I ran these commands as root from the actual terminal - the result was that screen blanking was disabled. This means that the .xinitrc was not running or with insufficient permissions at the time the command was executed. Any suggestions? Commented Oct 1, 2012 at 13:38
  • I added an answer with the suggestion.
    – Nakedible
    Commented Oct 1, 2012 at 15:36
  • I have gotten this to work by doing everything (except adding the .xinitrc file) in both the links you provided and it works for me. Commented Oct 4, 2012 at 1:20
  • "I fixed this problem by installing xscreensaver: $ sudo apt-get install xscreensaver And disabling it from within the screensaver settings. Not the most elegant of solutions but is worked for me." This was the only way i could get it to work. Thanks for the tip!
    – user8317
    Commented Jul 4, 2013 at 11:15

6 Answers 6

9

Edit /etc/xdg/lxsession/LXDE-pi/autostart and add these three lines

@xset s off
@xset -dpms
@xset s noblank

Log out, log in, verify it's working with

xset -q
2
  • This didn't work for me. I had also commented out the \@xscreensaver line that was in this file. When I ran xset -q (thanks for that suggestion!) I saw that my xset lines had had no effect. I tried uncommenting the \@xscreensaver line and rebooted and I can see that the xset lines took effect, but while this does stop DPMS kicking in, the screensaver now starts after 10 minutes.
    – ZoFreX
    Commented Jan 29, 2014 at 15:28
  • Please note I approved an edit (from Kaarel Kitsemets) that changed the path from LXDE/autostart to LXDE-pi/autostart, but since I am not an LXDE user, I am not certain this is correct.
    – goldilocks
    Commented Sep 24, 2015 at 16:04
41

You can enter the following three xset commands

xset s off         # don't activate screensaver
xset -dpms         # disable DPMS (Energy Star) features.
xset s noblank     # don't blank the video device

into the

/etc/X11/xinit/xinitrc

file (You should insert these after the first line).

5
  • 10
    Pupil becoming the teacher? ;)
    – Jivings
    Commented Oct 4, 2012 at 7:14
  • 1
    By default xset is not installed, so it cannot be run. You need to install x11-xserver-utils so you have an executable xset app. Commented Sep 7, 2015 at 22:13
  • Not sure what version or os you are using, but xset was installed on mine. This however did not seem to do anything for me. Commented Jan 2, 2017 at 5:06
  • @JasonGoemaat, try one of the other answers as this was what worked 4+ years ago. Commented Jan 2, 2017 at 5:17
  • 1
    On a headless pi, over ssh (when you know which display is running), add the display number explicitly e.g. xset -dpms -display :0...time saver … Commented Nov 12, 2017 at 14:00
27

I had the same issue. At raspberry pi forum I found this:

You need to edit your script that's starting X. In the default build with lightdm the file to edit is

/etc/lightdm/lightdm.conf

in the SeatDefaults section it gives the command for starting the X server which I modified to get it to turn off the screen saver as well as dpms

[SeatDefaults]
xserver-command=X -s 0 -dpms

That worked well for me - no more blank screen!

3
  • This works on the Pi 3! Much obliged!
    – djthoms
    Commented Apr 14, 2016 at 19:11
  • This always WORKED FOR ME on PI 2 and PI 3. All the other answers suggested by others for this question DID NOT WORK FOR ME.
    – ThN
    Commented Sep 30, 2016 at 15:18
  • I used the Debian Jessie Lite image (2017-03-02) but I don't have the lightdm folder?! Have installed matchbox window manager (not LXDE) Commented Apr 10, 2017 at 16:58
20

I fixed this problem by installing xscreensaver via

$ sudo apt-get install xscreensaver

and disabling it from within the screensaver settings. Not the most elegant of solutions but it worked for me.

8
  • 4
    This answer is awesome. None of the text file solutions worked for me. Not elegant? I disagree. This package will always be up to date with apt-get upgrades so I don't have to maintain it to keep it working. And, as a bonus, I can use a screensaver now. Thanks, Miles. Commented Mar 20, 2016 at 21:20
  • I don't know why, but I tried this answer and the console told me that it couldn't retrieve some files from repository. So, it quit installing. I even try to install xscreensaver using add/remove program. Still the same result. This may have worked in the beginning.
    – ThN
    Commented Sep 30, 2016 at 15:23
  • 1
    This worked for me on Raspberry Pi 3. It also put it into the main menu under Preferences. Commented Feb 26, 2017 at 21:15
  • 2
    This is what I did. I think it is the most elegant. Instead of futzing with files it is right there in the GUI. Then if I don't want one, I just set it to "No Screen Saver" and if I don't want blanking I either set it to 0 or to 999. I have a handful of systems and when I add a new one It is much easier to remember a setting that which files need to be modified.
    – SDsolar
    Commented Aug 5, 2017 at 1:51
  • 2018, and this is still the cleanest solution. Confirmed on Raspberry Pi 3B+
    – Stephan
    Commented Jun 1, 2018 at 1:40
3

As it was clarified in a comment that the commands work while being run from a terminal, but not from .xinitrc, and that Chromium is being started from .config/autostart/, I would suggest the following:

Create a shell script disableblank.sh that runs the xset commands and add an entry in .config/autostart/ calling that script. That way, everything is started with the same method and either both work or neither works.

Also, these commands affect the current running X window session and are configurable by the user. They should not be run as root, but the user Chromium is running as.

Not knowing exactly how you start your X, or other details, this is probably the safest way - although there probably is a more straightforward way.

2

It's the console blanking that is kicking in.

I tried several suggested methods, but the one that worked for me was to edit /etc/rc.local and add a setterm -blank 0 command:

setterm -blank 0

So the file looks like this afterwards:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# turn off console blanking
setterm -blank 0

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

exit 0

(entire file here to show exactly where I put it)

Essentially, the setterm -blank 0 command sets the terminal blanking period to 0 seconds (off), disabling the blanking which usually occurs. rc.local is executed at the end of the boot process with root privileges so it affects all the physical consoles (the TV & HDMI outputs here)

You could also change the command to include turning off the cursor (not the mouse pointer, text cursor in console):

setterm -blank 0 -cursor off

I've posted more on this on a few other questions, but this should fix your issue without resorting to drastic measures.

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