# Disable screen blanking in X-Windows on Raspbian [duplicate]

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.

## marked as duplicate by goldilocks♦Sep 24 '15 at 16:05

• 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 Oct 1 '12 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? – Salim Fadhley Oct 1 '12 at 13:38
• I added an answer with the suggestion. – Nakedible Oct 1 '12 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. – shaun5 Oct 4 '12 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 Jul 4 '13 at 11:15 ## 6 Answers 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  • 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 Jan 29 '14 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 Sep 24 '15 at 16:04 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). • – Jivings Oct 4 '12 at 7:14 • 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. – user2250957 Sep 7 '15 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. – Jason Goemaat Jan 2 '17 at 5:06 • @JasonGoemaat, try one of the other answers as this was what worked 4+ years ago. – Steve Robillard Jan 2 '17 at 5:17 • 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 … – Jonathan Komar Nov 12 '17 at 14:00 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! • This works on the Pi 3! Much obliged! – djthoms Apr 14 '16 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 Sep 30 '16 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) – TheStoryCoder Apr 10 '17 at 16:58 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.

• 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. – Wray Bowling Mar 20 '16 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 Sep 30 '16 at 15:23
• This worked for me on Raspberry Pi 3. It also put it into the main menu under Preferences. – Alan Jay Weiner Feb 26 '17 at 21:15
• 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 Aug 5 '17 at 1:51
• 2018, and this is still the cleanest solution. Confirmed on Raspberry Pi 3B+ – Stephan Jun 1 '18 at 1:40

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.

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

_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.