Raspberry Pi’s are powerful little devices. They are often used as “dashboard” devices for server monitoring, security cams, or to display webpages. Wondering how to disable sleep on a raspberry pi in 2021?
Raspberry Pi’s have a built-in feature called Screen blanking which turns the display black after 30 minutes of inactivity. Obviously, this isn’t ideal for dashboards as you want them running all the time.
A better option would be using your TV’s sleep settings to turn off the TV at a certain time. If you’re using a monitor instead of a TV, you probably won’t have the ability to turn it off or on at certain times. An alternative option would be using a smartplug and setting a schedule.
To disable the rpi screen blanking issues and disable sleep on a raspberry pi, follow the guide below.
Equipment List
Amazon productOption 1: Install XScreensaver
This is my preferred method of managing the screen blanking/sleep settings. With this method, you just type one line of code into the terminal and adjust the settings via the preferences menu.
How To Install Xscreensaver
1. To install xscreensaver, open a terminal and type:
sudo apt-get install xscreensaver
2. When it asks if you want to continue, click Y and press the Enter key for yes.
3. Reboot your raspberry pi. Either Click your raspberry pi icon in the top left corner > Shutdown > Reboot, or type this command:
reboot
4. After reooting, click the Raspberry Pi icon > Preferences > Screensaver. A message will pop up letting you know a daemon isn’t running. Click OK.
6. In the Screensaver preferences box, change the mode to Disable Screensaver.
7. Close the window and reboot the raspberry pi again. If the raspberry pi doesn’t go to sleep after 30 minutes, you have successfully disabled screen blanking on it!
Create the Directory (if not already created)
If you have issues with screen blanking even after disabling the screensaver above in Step 6, launch the nano file editor and edit the autostart config file.
A lot of times this folder will already be created (such as if you set your raspberry pi to automatically launch a website after a pi reboot). First, check if this file exists by typing this in a terminal:
sudo nano ~/.config/lxsession/LXDE-pi/autostart
If you receive an error message that says this folder doesn’t exist, create it.
cd .config
And then:
sudo mkdir -p lxsession/LXDE-pi
Now that the directory is created, either press the UP arrow key two times, or paste this in again to access the new folder you created:
sudo nano ~/.config/lxsession/LXDE-pi/autostart
Set Xscreensaver to Autolaunch after Reboot
If this file is empty, simply add the 3 lines of code below.
If there is already code in here (from configuring your raspberry pi to automatically open in full screen) add this code under the #@xscreensaver -no-splash
line, press the Enter key and add these 3 lines:
@xset s off
@xset -dpms
@xset s noblank
Press CTRL+X > Y > Enter to save the autostart file.
Then type reboot
to reboot your raspberry pi.
if you want to disable screen blanking – as well as launch a full screen webpage – on reboot, your config file will look like this:
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
#@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
point-rpi
@chromium-browser --start-fullscreen --start-maximized https://teams.microsoft.com/
How To Remove Xscreensaver
If you want to remove xscreensaver, open a terminal and type:
sudo apt-get remove xscreensaver
Other Helpful Raspberry Pi Articles:
My Homelab Equipment
Here is some of the gear I use in my Homelab. I highly recommend each of them.
- Server 2019 w/ Hyper-V
- Case: Fractal Design Node 804
- Graphics Card: NVIDEA Quadro K600
- CPU: AMD Ryzen 7 2700
The full list of server components I use can be found on my Equipment List page.
Just a comment about your URL not working in the autostart file. You need to make sure that the chromium command and the URL are all on the same line (no newline after the –start-maximized argument. Thanks for a great tutorial!
Thanks for the tip! I updated my doc and confirmed that your solution works perfectly.