Sunspot Home . . . . . . Joggler menu
Running CGI scripts from a web page to run C code, Sox, flite etc
-to first control the backlight and the Joggler i2c light sensor and (later) i2c external devices
In my (Debian)Slug and (Openwrt)Sweex and (Debian)Bifferboard I can run cgi scripts in /var/www/cgi-bin and have these run in turn bash scripts that can then run C code, sound players, text to speech etc.
On (Ubuntu)Joggler using lighttpd as downloaded I can run bash scripts and Blassic basic but NOT Flite, Sox, readlightsensor etc even though these run fine when I run the bash scripts that call them in a root SSH terminal.
The answer is to run lighttpd as root (just as in my other platforms)
BUT the Ubuntu lighttpd download refuses to do so!!
The fix is here
I have a set of scripts that use cgi files in /var/www/cgi-bin/scripts that allow a link on a web page to run Joggler programs.
The demo web page below is called after loading http://192.168.0.247/cgi-bin/scripts/scripts.cgi
using -
/var/www/cgi-bin/scripts/scripts.cgi |
#!/bin/sh #Decode query string IFS="&" # when the page is first opened load the text from pg-default.sh # has the variable page been given a value? # if not then show the default text echo "Content-type: text/html" #send first part of the html page |
The top part of the page is built by scripts.cgi from :-
/var/www/cgi-bin/scripts/scripts.html |
<html> <body bgcolor="#FFFFCC"> <font color="#009900" size="4" face="Arial, Helvetica, sans-serif"><strong>Joggler Control Scripts</strong></font></p> <font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/sound_test.sh">sound test </a></font> </font> <BR><BR> <font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/read_light_level.sh">read light level</a></font> <font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/play_a_wav.sh">play wav with Sox</a></font> <font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/screen_32.sh">bright screen</a></font> <font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/screen_12.sh">dim screen</a></font> <font size="3" face="Arial, Helvetica, sans-serif"><a href="http:/cgi-bin/scripts/scripts.cgi?page=scripts&string=/var/www/cgi-bin/scripts/screen_0.sh">dark screen</a></font> |
the clicked link makes page = scripts and so the file pg-scripts.sh runs
/var/www/cgi-bin/scripts/pg-scripts.sh |
#!/bin/sh # send all this to the web page echo '<font color=blue size=3 face=Arial>' echo '<font color=red size=3 face=Arial>' # run the script with the name string $string |
pg-scripts.sh runs this if the clicked link made string=/var/www/cgi-bin/scripts/sound_test.sh
/var/www/cgi-bin/scripts/sound_test.sh |
#!/bin/bash echo "<BR> sound test now <BR>" flite -t ' eff lite is speaking ' date |
pg-scripts.sh runs this if the clicked link made string=/var/www/cgi-bin/scripts/read_light_level.sh
/var/www/cgi-bin/scripts/read_light_level.sh |
#!/bin/bash echo "<BR><BR>Joggler light sensor value = " # dump the first reading - seems to be in memory from last time light level was read # now write the light reading to the web page echo "<BR><BR>" flite -t 'the light level is' |
pg-scripts.sh runs this if the clicked link made string=/var/www/cgi-bin/scripts/play_a_wav.sh
/var/www/cgi-bin/scripts/play_a_wav.sh |
#!/bin/bash echo "<BR><BR>" date |
pg-scripts.sh runs this if the clicked link made string=/var/www/cgi-bin/scripts/screen_32.sh
/var/www/cgi-bin/scripts/screen_32.sh |
#!/bin/bash echo -n 32 > /sys/class/backlight/openframe-bl/brightness echo "<BR>Screen brightness is now 32 <BR><BR>" date |
Then scripts.cgi closes the html to finish the page.
§§§§§§§§§§§§§§§§§§§§§§§§§§§
The default below is used when http://192.168.0.247/cgi-bin/scripts/scripts.cgi is first called by the browser
/var/www/cgi-bin/scripts/default.sh |
#!/bin/sh #Generate the message that is first seen echo "<BR><font color=red size=3 face=Arial>" |
Remove the scroll bar in the Joggler Firefox display
My home page is a table matrix of 11 x 7 icons that are 60 x 60 pixels each (easy to click on with a finger tip).
There are also some Google Gadgets (weather, birthdays, clock) and the BBC iPlayer gadget.
To save precious screen area I wanted to remove the scroll bar on the right of the Firefox screen when in full screen mode.
Method
Install Stylish as a Firefox add-on.
By following these instruction I added a script to kill the scroll bar for the home page URL only
(as displayed in the Joggler - remote users still see the scroll bar)
The script to add is
no_scroll |
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); scrollbar {visibility:collapse !important; } |
Notes for future use
Sound volume control
The sound volume van be controlled from the command line
(perhaps in a script controlled by a web page) to any percentage of full on with, for example
amixer -c 0 -- sset Master playback 90%
Sunspot Home. . . . . Joggler menu