Web Screensaver

| Comments

We have just started a new project similar to our music player, Gramola, to show our photos in a web browser, after our disappointment with existing solutions such as Piwigo or Gallery2. We hope that you’ll hear some more about it in the future.

In the meantime, while deciding about features to implement, a slideshow mode obviously came out as part of them. And we though about how cool would it be to be able to have the photo slideshow as an screensaver for your desktop.

So in order to achieve this, Javier wrote a tiny bash script that will open any webpage in a fullscreen browser after a certain time of inactivity, and it will close itself when it detects activity again. So effectively it’s a screensaver that shows websites.

We use xprintidle to get the time of inactivity and chromium-browser (not google-chrome) to open the web as an app with some chromium specific features like —start-maximized

Here’s the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

app="http://www.google.com/trends/hottrends/visualize?nrow=5&ncol=5"
wait=10000 #Time in miliseconds

chromium_id=""
while true; do 
idle=`xprintidle`
if [ $idle -gt $wait ]; then
    if [ -z $chromium_id ]; then
    
    chromium-browser --app=$app --start-maximized --fast-start &>> chromium.log &
    chromium_id="$!"
    echo "Away, running screensaver (id:$chromium_id)"
    fi
elif [ $chromium_id ]; then #Screensaver is running
    echo "Welcome back, closing screensaver (id:$chromium_id)"
    kill "$chromium_id"
    chromium_id=""
fi
sleep 1
done

Here’s a demo of what will happen if you run it. Notice how the screensaver stops once you move the cursor:

So, once we finish the photo app with the slideshow feature, we will be able to use it as an screensaver for our desktop computer/rasbperry pi/laptop…

Get the latest version of this code in our project page in bitbucket.

Comments