Turning Firefox into a web screensaver using a bash script
There’s a little program available for windows that lets you turn your browser into a screensaver, looping through various web content. However, there are 2 things wrong with it. Firstly it costs money. Secondly it doesn’t run on linux.
So what? – we have bash – and after a bit of digging around this morning and combining a few bits and pieces this is my version for Ubuntu
Firstly, in order to run firefox full screen we need the AutoHide plugin, which appears to have been written by someone with an interesting sense of humour.
Secondly, a small alteration needs to be made to the javascript prefs file (.mozilla/firefox/$profile/prefs.js, $profile = your profile). THIS MUST BE DONE WITH THE BROWSER CLOSED as Firefox overwrites the file on shutdown. Add these two lines at the end of the file:
user_pref("browser.link.open_external", 1);
user_pref("browser.link.open_newwindow", 1);
Now that’s done there’s just a little bash script. Feel free to hack but if you improve it please let me know! I just saved the following few lines as a file “Webscreen” in my home directory:
#!/bin/bash
remoteclient=$(find /usr/lib/ -type f -name mozilla-xremote-client | grep -m 1 xulrunner)
if [ `ps -e | grep firefox | wc -l` -eq 0 ]; then
/usr/bin/firefox -fullscreen &
sleep 5
fi
while [ `ps -e | grep firefox | wc -l` -gt 0 ]; do
urls=$(cat /home/huff/Desktop/pages)
for i in $urls
do
$remoteclient -a firefox "openurl($i)"
if [ $? -gt 0 ]; then
echo "Firefox not running or ignoring me, bailing out...."
killall firefox
exit 0
fi
sleep 15
done
done
exit 0
Note the path to the mozilla-xremote-client – this is correct on Ubuntu Jaunty but I had to use find to well, you know, find it:
find /usr/lib -iname \*mozilla-xremote\*
As can be seen the script takes the pages you want to cycle through from a text file called (I felt quite pleased with this) “pages” on the Desktop, one url on each line such as:
http://bbc.co.uk
http://flickr.com
http://yoursite.whatever.com
and scrolls through the selection every 15 seconds.
The last detail is to
chmod +x ~/Webscreen
and add a Custom Application Launcher to the panel. Thanks to mozilla for continuing the command line options started by Netscape and the cool AutoHide plugin, this was pretty easy. Hope it helps someone.
In: Linux · Tagged with: bash, command line, command line options, firefox, Linux, screensaver, ubuntu, xulrunner

on 17/10/2011 at 3:03 pm
Permalink
Hi!,
I just wanted to let you know that your post has really helped me. I ended up controlling Firefox through Python, but your user_prefs are a lifesaver
Thanks!
Nick
on 22/10/2011 at 7:08 am
Permalink
AutoHide doesn’t seem to support the newer releases of Firefox. Opera has a -fullscreen option out of the box. Here’s a variation on your script built for opera:
#!/bin/bash
if [ `ps -ef | grep "opera -fullscreen" | grep -v grep | wc -l` -eq 0 ]
then
opera -fullscreen &
sleep 5
fi
while [ `ps -ef | grep "opera -fullscreen" | grep -v grep | wc -l` -gt 0 ]; do
urls=$(cat /etc/webscreen/pages)
for i in $urls
do
opera -fullscreen -activetab -remote “openURL($i,noraise)”
if [ $? -gt 0 ]; then
echo “Something is wrong, bailing out….”
killall opera
exit 1
fi
sleep 15
done
done
exit 0