Prevent Your Raspberry Pi From Sleeping

You're using your Pi and your monitor keeps going blank and it's driving you mad.

There are various methods to accomplish this so we'll look at a few. That way if you find one isn't working for you, you'll have some alternatives.

setterm - terminal blanking

On a per session basis, you can run:

setterm -blank 0 -powerdown 0

This will set the timeout of your monitor to 0, which will prevent it from going to sleep.

If you get yelled at about permissions, try "sudo setterm" instead.

You might not want to enter these commands every time you boot up your Pi. In this case, open up your .bashrc file (or .extras or other custom file you might use).

nano ~/.bashrc

At the end of the file add a new line with the setterm command you entered before.

setterm -blank 0 -powerdown 0

Hit ctrl+x to exit, 'y' to save your changes and enter to save the file.

Note: the default value for the -blank option is 0 so it may be excluded

Now when you boot up, your monitor will never sleep.

kbd configuration - terminal blanking

Open up your configuration:

sudo nano /etc/kbd/config

Find the line for BLANK_TIME and POWERDOWN_TIME and set them to 0.

BLANK_TIME=0
POWERDOWN_TIME=0

If these lines doesn't exist go ahead and add them.

lxde configuration - Xsession blanking

The previous methods should work for the terminal. This method should prevent your screen saver from coming on in the GUI.

Open up your lxde autostart file:

sudo nano /etc/xdg/lxsession/LXDE/autostart

If your Pi is newer, the file you'll need to change may be:

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

Add these lines:

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

lightdm configuration - Xsession blanking

If adding those settings to your LXDE autostart didn't work, this might help if you're booting straight into the GUI.

Open your lightdm configuration:

sudo nano /etc/lightdm/lightdm.conf

Anywhere below the [SeatDefaults] header, add:

xserver-command=X -s 0 -dpms

This will set your blanking timeout to 0 and turn off your display power management signaling.