How to Install and Autostart XScreenSaver on Ubuntu 18.04, Ubuntu 19.04
XScreensaver is a screen saver and locker for the X11 display server. Ubuntu ships with the gnome-screensaver
, but it never worked out of the box. This tutorial shows you how to install XScreenSaver on Ubuntu 18.04/Ubuntu 19.04 and how to autostart it at boot time.
Install XScreenSaver on Ubuntu 18.04, Ubuntu 19.04
XScreensaver is included in Ubuntu software repository, so you can easily install it by running the following command in a terminal window.
sudo apt install xscreensaver
To check your XScreenSaver version, execute the following command:
xscreensaver --help
Now you can start XScreenSaver program from the Unity Dash or your preferred application launcher.
Upon first start, the program will ask you to start the XScreenSaver daemon. Click OK to start the daemon. By default, a randomly screensaver will be displayed after 10 minutes inactivity.
How to Get XScreenSaver Autostart at boot time
Since Ubuntu comes with gnome-screensaver
, which is a fork of XScreenSaver, we need to remove gnome-screensaver
in order to autostart XScreenSaver at boot time.
sudo apt remove gnome-screensaver
Then open startup applications
.
Add a new startup entry like below. Enter xscreensaver -nosplash
in command field.
Reboot your computer and XScreenSaver daemon should be automatically started when you login. If you open XScreenSaver program again, it won’t tell you to start the daemon because the daemon has already been started.
Autostart with Systemd service
Alternatively, you can get XScreenSaver autostart at boot time with Systemd, which is used by Ubuntu since 15.04 (Willy Werewolf).
First, execute the following command to create a directory for storing Systemd service file of individual users.
mkdir -p ~/.config/systemd/user/
Then create xscreensaver.service
file with a command line text editor such as Nano
nano ~/.config/systemd/user/xscreensaver.service
Copy and paste the following text into the fie.
[Unit] Description=XScreenSaver [Service] ExecStart=/usr/bin/xscreensaver -nosplash [Install] WantedBy=default.target
To save the file in Nano text editor, press CTRL+ O
, then press Enter to confirm. Press CTRL+X
to exit. Finally, enable this service so that XScreenSaver will be automatically started at boot time.
systemctl --user enable xscreensaver
Wrapping Up
I hope this tutorial helpd you install and autostart XScreenSaver on Ubuntu 18.04 and Ubuntu 19.04 desktop. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package xsreensaver
It’s xscreensaver, not xsreensaver.
I’m very new to Ubuntu, was a Windows user for many years. Installed the screensaver program, but is there a way to use my own pictures as the screensaver? Have tried the advanced screen but don’t seem to get anywhere. Not sure what I’m missing…
Hi Bill,
I don’t use Ubuntu, but I do use xscreensaver (on PCLinuxOS), with my own folder of pictures being displayed. In addition to the regular xscreensaver package, I also installed a package called “xscreensaver-gl “, which is described thus:
A set of GL screensavers
The xscreensaver-gl package contains even more screensavers for your
mind-numbing, ambition-eroding, time-wasting, hypnotized viewing
pleasure. These screensavers require OpenGL or Mesa support.
Install the xscreensaver-gl package if you need more screensavers for
use with the X Window System and you have OpenGL or Mesa installed.
That package includes a screensaver named “glslideshow” which has in its options the folder to take the slideshow from.
~Enjoy!
Shimon
Your command “$ sudo apt install xscreensaver” failed to install most of the hacks (aka screensavers).
I found this command “$ sudo apt-get install xscreensaver xscreensaver-data-extra xscreensaver-gl-extra” was successful at installing all of the hacks (aka screensavers).
Thankyou thank you, thank you. After two hours of utter frustration, a simple answer that simply worked. A few more people like you and we could double the popularity of LINUX. (of course, if the installed version just work, we could quadruple it….)
I’m sorry to say this doesn’t work in Ubuntu Server 20.04 with lubuntu-desktop on a Raspberry Pi
Having read something about adding delays I added a Restart to the systemd unit and that seems to work
Excellent, particularly how to set up for Systemd, I failed to get a printer daemon to autostart before because I could not understand the syntax for it. Good work!
Hi mate,
I’ve been a subscriber for a couple of years now. Your tips and suggestions are always very helpful. Thank you and keep up the good work. It is greatly appreciated.
Best regards,
Billy