Linux Format

Touchy Firefox

-

I am trying to build an informatio­n system using a Raspberry Pi running Raspbian and a touch screen. I thought I could drive everything from Firefox running in fullscreen mode and displaying everything in HTML. I have some recollecti­on of a kiosk mode option, but I can’t find it. Can I do what I want? If so, how?

The other thing that would be useful is to be able to know when there has been no input for a while and return to either a home page or a slideshow. Could I somehow use the screensave­r to run a command to load a new page? Liam Donnelly I have set up a system like this and found a couple of ways of doing it. The simplest is to use the mKiosk extension. The mKiosk add-on not only has an option to start the browser fullscreen, it can also jump to a specific page after a set period of inactivity. There are several other options you can use to run Firefox as you want. However, I found it didn’t quite suit my needs and switched to using a couple of other extensions and a shell script. First, install the Run Fullscreen extension in

Firefox. This does exactly what it says and causes Firefox to run in fullscreen mode. With only left-mouse button control offered by the touchscree­n, this means the browser is locked in fullscreen mode. I then used a script that called xprintidle to reload the home page after five minutes of idle. The reload command is sent via the remote control extension from https://addons.mozilla.org/en-GB/firefox/ addon/remote-control. The remote control extension allows you to send JavaScript commands with telnet or netcat. By default, it only listens on localhost, using port 32000, which can be changed in the preference­s. To force loading of a local page, you would use something like echo 'window.location="file:///www/index. html"' | netcat localhost 32000 &

All that remains is to run a script that checks how long the system has been idle, using xprintidle . This command prints the number of millisecon­ds since the last input event, which is a little too precise for this applicatio­n so we divide it by 1,000. Then we compare that with the limit we have set, if the limit is exceeded we force a page load. If not, we work out how long is left and set it to go to sleep for that time before checking again. The full script is below, the MAX_IDLE setting is how long the system should be idle for before loading the default page, in seconds. #!/bin/sh MAX_IDLE=300 while true; do let “CUR_IDLE = $(xprintidle) / 1000” if [[ $CUR_IDLE -lt $MAX_IDLE ]]; then

sleep $(( MAX_IDLE - CUR_IDLE )) else

echo ‘window.location="file:///www/index. html"’ | netcat localhost 32000 & sleep $MAX_IDLE fi done

The script runs forever, you could even add a line at the top to start Firefox in the first place then run this script from the autostart file or you could start Firefox independen­tly, it is up to you.

Newspapers in English

Newspapers from Australia