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.
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:
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