Tuesday, August 4, 2009

Some more tweaks to Zubuntu

/bin/bl
For some reason in the /bin/bl script the line setting the highest brightness is marked out and the MAX_BRIGHTNESS is set to 15. So I unmarked the following line:

#MAX_BRIGHTNESS=`cat /sys/class/backlight/$DRIVER/max_brightness`
Next, to restore the original brightness value after suspend/lid closed (according the original script the brightness is set to the maximum value). I added after
elif [ "$1" = "on" ]; then
the following lines:
if [ -a /tmp/BrightnessBeforeOff ]; then
echo `cat /tmp/BrightnessBeforeOff` >> $BRIGHTNESS_FILE
rm /tmp/BrightnessBeforeOff
else
echo $MAX_BRIGHTNESS >> $BRIGHTNESS_FILE
fi
which reads the brightness level from /tmp/BrightnessBeforeOff. After
elif [ "$1" = "off" ]; then
I added the following:
echo $BRIGHTNESS > /tmp/BrightnessBeforeOff
which saves the brightenss level to /tmp/BrightnessBeforeOff.

Last, I added a third case, "low", to the if, before the else statement, I added,
elif [ "$1" = "low" ]; then
echo 5 >> $BRIGHTNESS_FILE
which sets a low level brightness.
Then I use Xbindkeys to to bind Fn-5,6 and 7 to /bin/bl on, low and off respectively.
The whole thing can be downloaded from here.

OSD
Next, I installed osd_cat for some nice on-screen-display:
apt-get install xosd-bin
and I created the following script /bin/osd.sh
#!/bin/bash
OSDFONT="-*-*-medium-r-normal-*-16-*-*-*-*-*-*-*"
DELAY=3

killall osd_cat -q
if [ "$2" = "" ]; then
echo "$1" | osd_cat -d $DELAY -P 5 -p bottom -c yellow -O 8 -A right --font=$OSDFONT -o -110&
else
osd_cat -d $DELAY -T "$1" -b percentage -P $2 -p middle -c $3 -O 8 --font=$OSDFONT
fi
which can be used to display messages or percentage bar (for the brightness or battery level) and can be downloaded from here.

/bin/dispaly-brightness.sh
here too the MAX_BRIGHTNESS is marked out, so I unmarked it. I also added calls to osd.sh (see above) to display the brightness level. It can be found here.
I linked Fn-3 and 4 to /bin/display-brightness.sh down and up using xbindkeys.

/etc/zaurusd/scripts/zaurus-hinge
IIRC the values in the zaurus-hinge script are switched, which breaks the automatic rotation. The values should be for landscape:
STATE = 0
and for portrait:
STATE = 2

I also added a call to osd.sh here too, to report the rotation. In the landscape section, After bl on I added:
osd.sh "Landscape mode"&
and in the portrait section, after /usr/bin/xrandr -o right I added:
osd.sh "Landscape mode"&
/bin/batStat.sh
I created /bin/batStat.sh to report the battery status to the screen.
#!/bin/bash

TIMEOUT=3
HIGH=95
MED=50


bat=`apm`
stat=${bat:0:3}
bat=${bat:(-4)}
bat=${bat:0:`expr length "$bat"`-1}
bat=$((bat))


color=green
if [ "$stat" = "Off" ]; then
stat="Off-line"
if [ $bat -lt "$HIGH" ]; then
color=yellow
fi
if [ $bat -lt "$MED" ]; then
color=red
fi
else
stat="On-line"
if [ $bat -lt "$HIGH" ]; then
color=yellow
fi
if [ $bat -lt "$MED" ]; then
color=red
fi
fi
killall osd_cat -q
osd.sh "Battery: $stat ($bat%)" $bat $color
This script, when runs prints the battery status to the screen. And changes the color according to the charge level of the battery. It also indicate if he battery is charging. The script can be downloaded from here.

I linked the script to Fn-8 (saving 9 and 0 for the volume control).

HDD led
Last, a nice tweak is to connect the green (mail) led to the sd access. This can be done by,
echo mmc0 > /sys/class/leds/corgi\:green\:mail/trigger
This can be permanently changed by adding the line to ~/.xinitrc. to see the avalabe triggers and the active one type,
cat /sys/class/leds/corgi\:green\:mail/trigger


No comments:

Post a Comment