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

install xscreensaver on ubuntu 18.04 19.04

Now you can start XScreenSaver program from the Unity Dash or your preferred application launcher.

xscreensaver ubuntu

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.

xscreensaver daemon ubuntu 18.04

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.

ubuntu startup applications

Add a new startup entry like below. Enter xscreensaver -nosplash in command field.

xscreensaver ubuntu autostart

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 🙂

Rate this tutorial
[Total: 3 Average: 5]

10 Responses to “How to Install and Autostart XScreenSaver on Ubuntu 18.04, Ubuntu 19.04

  • Anonymous
    5 years ago

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package 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).

    • Daniel Garner
      4 years ago

      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

    Nov 26 20:16:14 ubuntu systemd[1983]: Started XScreenSaver.
    Nov 26 20:16:15 ubuntu xscreensaver[1990]: xscreensaver: 20:16:15: Can't open display: :0.0
    Nov 26 20:16:15 ubuntu xscreensaver[1990]: xscreensaver: 20:16:15: running as ubuntu/ubuntu (1000/1000)
    Nov 26 20:16:15 ubuntu xscreensaver[1990]: xscreensaver: 20:16:15: Errors at startup are usually authorization problems.
    Nov 26 20:16:15 ubuntu xscreensaver[1990]:               But you're not logging in as root (good!) so something
    Nov 26 20:16:15 ubuntu xscreensaver[1990]:               else must be wrong.  Did you read the manual and the FAQ?
    Nov 26 20:16:15 ubuntu xscreensaver[1990]:               https://www.jwz.org/xscreensaver/faq.html
    Nov 26 20:16:15 ubuntu xscreensaver[1990]:               https://www.jwz.org/xscreensaver/man.html
    Nov 26 20:16:15 ubuntu systemd[1983]: xscreensaver.service: Main process exited, code=exited, status=1/FAILURE
    Nov 26 20:16:15 ubuntu systemd[1983]: xscreensaver.service: Failed with result 'exit-code'.
    

    Having read something about adding delays I added a Restart to the systemd unit and that seems to work

    [Unit]
    Description=XScreenSaver
    [Service]
    Restart=on-failure
    RestartSec=5
    ExecStart=/usr/bin/xscreensaver -nosplash
    [Install]
    WantedBy=default.target
    
  • 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!

  • BIlly J
    1 year ago

    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

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here