Those of you on recent versions of Ubuntu may find the default screensaver slightly lacking. Gnome-screensaver’s blank screen can be a bit of a bore, luckily there are alternatives such as xscreensaver. However, the alternatives may be overkill if you just want a simple slideshow screensaver, so here’s bash script that does just that.
Xscreensaver may seem like the obvious route to more interesting screensavers on Ubuntu. This was the route I previously took with Ubuntu, configuring the webcollage screensaver to point to a local directory for showing images from. However, if you use the ever-popular caffeine to stop screensavers and lock-screens kicking in when viewing full screen videos or games you might run into some problems. (If you’re interested in using xscreensaver there is a script that you can use to stop it running while a full-screen application has focus.) All I wanted was a simple slideshow to show off my pictures when I left my PC alone, so to avoid the workarounds needed for xscreensaver to work properly with the most recent Ubuntu I made my own bash script for it instead.
The script uses feh, a simple tool for displaying images. You can install it with this command:
sudo apt-get install feh
The script also uses xprintidle, another simple tool – this time for identifying the time since the last input from a user. This can be installed with the following command:
sudo apt-get install xprintidle
With both of these tools installed a simple bash script can be used to start showing a slideshow of images when a certain period of inactivity has taken place. I have made two scripts which use the these tools, the first of these simply starts a screensaver after a period of inactivity:
The script should be downloaded into a folder containing images (or links to the images) you want to appear in the slide show. The folder can also contain folders (or links to folders) containing the images you want the screensaver to show.
To start this script a command similar to the following should be used:
bash path/to/script/screensaver.sh time
The time value should be the number of seconds the script should wait when no input is detected before starting to show the slideshow. For example; ‘screensaver/screensaver.sh 120′ would cause the script to start showing images from the screensaver folder after 2 minutes of inactivity.
A command for running the script can be added as a start up application to get it to run automatically.
The script is designed to not start showing the slideshow if a full-screen piece of software is running in the foreground. This means the screensaver should not kick in if you’re watching a full-screen video (through either a media player or browser). Once the slideshow starts it can be closed with the escape key.
An alternative version of the script is also available here:
This version uses the same setup and can be executed with a command similar to the following:
bash path/to/script/screensaverwithlock.sh time
This version makes use of Ubuntu’s lock screen – forcing users to enter a password when wanting to close the slideshow (and leave the screensaver). This is included because those who still want their Ubuntu to lock after a certain amount of time may find that the screensaver will stop the gnome-screensaver (and lock) from automatically kicking in if they have caffeine running. (If you are running this script with gnome-screensaver still doing the locking and without caffeine, you should make sure that the screensaver will kick in sometime before the lock or else you won’t get to see the slideshow.)
As I keep iterating this is a very simple script, I’ve tried to make it as secure as possible but it may not be suitable for machines where access needs to be tightly controlled.
The scripts should be usable on other linux platforms that can use bash scripts, feh and xprintidle (and gnome’s lock for the locking script).
Feel free to modify the scripts if you can think of any improvements.