Here is my script:
[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']#!/bin/sh
ONE=$(grep Spitzkbd /proc/interrupts|md5sum)
while true
do
sleep 240
PLAYING=$(mpc|grep "play"|wc -l)
if [ "$PLAYING" = 0 ]; then
TWO=$(grep "Spitzkbd\|ts" /proc/interrupts|md5sum)
#echo $ONE $TWO
if [ "$ONE" = "$TWO" ]; then
apm -s
fi
fi
ONE=$TWO
done[/div]
File with interrupts (/proc/interrupts) looks like this:
[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\'] CPU0
3: 1240 SC ohci_hcd:usb1
6: 12 SC pxa_i2c-i2c.1
11: 0 SC pxa27x_udc
16: 0 SC SSP
17: 34 SC LCD
18: 2214 SC pxa_i2c-i2c.0
23: 158689 SC pxa2xx-mci
25: 17071 SC DMA
26: 295976 SC ost0
73: 0 GPIO MMC card detect
75: 40 GPIO ts
76: 87 GPIO Spitzkbd Sense
77: 0 GPIO Spitzkbd HP Type, sharpsl_rc
80: 0 GPIO Spitzkbd Sync
81: 77 GPIO Spitzkbd Sense
85: 0 GPIO Fatal Battery
98: 56 GPIO Spitzkbd Sense
100: 79 GPIO Spitzkbd Sense
102: 158 GPIO Spitzkbd Sense
103: 763 GPIO Spitzkbd Sense
154: 0 GPIO Battery Cover
155: 82 GPIO Spitzkbd Sense
158: 0 GPIO PCMCIA0 CD
159: 30 GPIO Spitzkbd PwrOn
160: 23 GPIO Spitzkbd SWB
161: 4 GPIO Spitzkbd SWA
165: 0 GPIO CO
169: 10693 GPIO ide0
179: 0 GPIO AC Input Detect
180: 0 GPIO Spitzkbd HP
Err: 0
[/div]
I think ide0 contains number of interrupts for cf card and pxa2xx-mci contains number of interrupts for sd card.
If you want to check activity of network card just check output of ifconfig and look for eth0, ppp0 wifi activity represented by number of bytes,sent/received.
In my case it was not important how much keys was pressed i just needed to know if anything happened so i used md5sum to check that.
There is a lot of ways to achieve result which You need, just peek in /proc or /sys and with simple script monitor what is happening in those files while You are doodling with zaurus and then write script to use that information and react.
You can use beeping instead led flash. Or you can try aosd_cat as a OSD visualizer.
I have written a small utility to show vital signs of my zaurus. I connected it to a keypress using .xbindkeysrc:
Look at "#show" battery section. When you press FN and 0 (zero) then /bin/batt script is executed.
Also Fn+9 is mpd toggle and fn+8 and Fn+7 is next and prev song
[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']###########################
# xbindkeys configuration #
###########################
#
# Version: 0.1.3
#
# If you edit this, do not forget to uncomment any lines that you change.
# The pound(#) symbol may be used anywhere for comments.
#
# A list of keys is in /usr/include/X11/keysym.h and in
# /usr/include/X11/keysymdef.h
# The XK_ is not needed.
#
# List of modifier (on my keyboard):
# Control, Shift, Mod1 (Alt), Mod2 (NumLock),
# Mod3 (CapsLock), Mod4, Mod5 (Scroll).
#
# Another way to specifie a key is to use 'xev' and set the
# keycode with c:nnn or the modifier with m:nnn where nnn is
# the keycode or the state returned by xev
#
# This file is created by xbindkey_config
# The structure is :
# # Remark
# "command"
# m:xxx + c:xxx
# Shift+...
#keystate_numlock = enable
#keystate_scrolllock = enable
#keystate_capslock = enable
#Brigtness Down
"display-brightness.sh down"
m:0x40 + c:12
Mod4 + 3
#Brightness Up
"display-brightness.sh up"
m:0x40 + c:13
Mod4 + 4
#Volume Down
"pcm down"
m:0x40 + c:10
Mod4 + 1
"pcm down"
F19
#Volume Up
"pcm up"
m:0x40 + c:11
Mod4 + 2
"pcm up"
F20
#show battery
"/bin/batt osd"
m:0x40 + c:19
Mod4 + 0
#toggle mpd
"mpc toggle"
m:0x40 + c:18
Mod4 + 9
"mpc toggle"
F18
#prev mpd
"mpc prev"
m:0x40 + c:16
Mod4 + 7
#next mpd
"mpc next"
m:0x40 + c:17
Mod4 + 8
#Right Mouse Click
"xte 'mouseclick 3'"
Control + b:1 (mouse)
#middle mouse click
"xte 'mouseclick 2'"
Shift + b:1
#rotate
"/bin/rot"
F10
"xte 'key Delete'"
Mod4 + c:22
#
#f1
#"xte 'key f1'"
# Mod4 + 1
#rotate screen
"/bin/rot"
m:0x40 + c:15
#fake alt-tab
"xte 'keydown Alt_L' 'key Tab' 'keyup Alt_L'"
c:67
"xte 'keydown Alt_L' 'key Tab' 'keyup Alt_L'"
F17
#fake alt-f4
"xte 'keydown Alt_L' 'key F4' 'keyup Alt_L'"
c:96
#show desktop
"xte 'keydown Alt_L' 'key l' 'keyup Alt_L'"
c:107
#
# End of xbindkeys configuration[/div]
It is helpful to use xev to check which codes are generated by X while pressing keyboard keys.
Here is a batt script:
It shows some nice information about Z
[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']#!/bin/sh
a=$(cat /sys/devices/platform/sharpsl-pm/battery_percentage)
f=$( free|grep Mem|awk '{ print $1 int($4/1024) }'|tail -n 3|tr "\n" " ")
l=$(top -b -n 1|grep "load average"|cut -d "," -f 3-6|cut -d ":" -f 2)
d=$(date)
s=$(amixer sget PCM|grep "\["|cut -d " " -f 4,6)
TEKST=$(echo -e "PCM\n$s\n$d\nbatt:$a \n$f \nload:$l")
echo -e "batt:$a $f load:$l"
if [ "$1" = "osd" ]; then
aosd_cat -d 5000 -e 0 -F "Trebuchet 30" -s 3 -S 100 -r 1 -g 1 -b 0 -x 30 -y 30 -t "$TEKST"
fi
[/div]
And one more:
[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']pcm script (used to change volume)
#!/bin/sh
STEP=3
if [ ! -n "$1" ]; then
echo "max / current"
amixer sget PCM
elif [ "$1" = "up" ]; then
amixer sset PCM $STEP"%+"
elif [ "$1" = "down" ]; then
amixer sset PCM $STEP"%-"
else
echo -e "\nUsage:\n\t `basename $0` [up | down]\n"
fi[/div]
And if I remember correctly I have changed slightly standard zubuntu script to change display brightness.
[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']#!/bin/sh
# display-brightness.sh
# simple script to set display-brightness for zaurus clamshell
# author: patrick steiner <[EMAIL PROTECTED]>
# modified by: Ian Munsie <[EMAIL PROTECTED]>
# modified by: Paul M "speculatrix" - for Spitz/Zubuntu
# version: 1.02 | 15/12/2008 21:48 GMT
STEP=5
MAX_BRIGHTNESS=47
MIN_BRIGHTNESS=0
DRIVER="`ls /sys/class/backlight/|head -n 1`"
BRIGHTNESS_FILE="/sys/class/backlight/$DRIVER/brightness"
BRIGHTNESS=`cat /sys/class/backlight/$DRIVER/actual_brightness`
# this gives bad number - 15 is max, 16 is off!
#MAX_BRIGHTNESS=`cat /sys/class/backlight/$DRIVER/max_brightness`
POWER_FILE="/sys/class/backlight/$DRIVER/bl_power"
POWER_ON=0
#POWER_OFF=1
if [ ! -n "$1" ]; then
echo "max / current"
echo "$MAX_BRIGHTNESS / $BRIGHTNESS"
elif [ "$1" = "up" ]; then
test -x /usr/bin/bl && bl on
echo $POWER_ON >> $POWER_FILE
if [ $BRIGHTNESS -lt $MAX_BRIGHTNESS ]; then
let BRIGHTNESS=$BRIGHTNESS+$STEP
if [ $BRIGHTNESS -ge $MAX_BRIGHTNESS ]; then
let BRIGHTNESS=$MAX_BRIGHTNESS
fi
echo $BRIGHTNESS >> $BRIGHTNESS_FILE
fi
elif [ "$1" = "down" ]; then
test -x /usr/bin/bl && bl on
echo $POWER_ON >> $POWER_FILE
if [ $BRIGHTNESS -gt $MIN_BRIGHTNESS ]; then
let BRIGHTNESS=$BRIGHTNESS-$STEP
if [ $BRIGHTNESS -le $MIN_BRIGHTNESS ]; then
let BRIGHTNESS=$MIN_BRIGHTNESS
fi
echo $BRIGHTNESS >> $BRIGHTNESS_FILE
fi
elif [ "$1" = "off" ]; then
if [ $BRIGHTNESS -ne 0 ];then
echo "$BRIGHTNESS" >/tmp/backlight
echo 0 > $BRIGHTNESS_FILE
fi
elif [ "$1" = "on" ]; then
cat /tmp/backlight > $BRIGHTNESS_FILE
rm /tmp/backlight
else
echo -e "\nUsage:\n\t `basename $0` [up | down]\n"
fi
[/div]
Combined together with .xbindkeyrc, those give quite nice result in usability of the zaurus. Dont forget ro run xbindkeys in your ./homedir/.xinitrc. the saver script is also executed there with background option (& ampersand at the end of a command)
BTW I use matchbox WM so there is not much to put in panel to monitor OS condition thats why i have those scripts.
Aosd_cat is quite slow to start but I use it rarely so it is not a problem.