Switch+dzen

Well Ubunut Intrepid may turn out to be great, but the recent ubuntu upgrade on my part proved to me how tired I was of dealing with apt and it’s pkg management system. How many debian users actually know what it’s really doing?

So I switched. To Arch.

Lately it seems like every useful tip I’ve gleaned has been from either the gentoo or arch wiki, so I had narrowed it down to one of the two. Both are appealing for their BSD style init systems and simple script based pacakge systems. Gentoo is full source though which, while not really a negative for most modern systems, was something I didn’t want to be restricted to. Arch allows a flexible binary or source build system, although the actual repo’s are binary. I love the rolling kernel too, no more waiting 6 months to get the latest, risking a broken system by upgrading in between.

In the process of switching I have fine-tuned things to the extreme. One of the tweaks is the battery status bar I use. It’s just a simple shell script that outputs formatted text to dzen2. It always bugged me that the script didn’t notice the charging state. After a simple little change, it does.

#!/bin/sh
#
# original script by lyon8 <lyon8@gmx.net>
# modifications from original by <sean.escriva@gmail.com>
# show your laptop battery state in dzen
 
BG='#1c2636'  # dzen backgrounad
FG='#99ffff'  # dzen foreground
W=150         # width of the dzen bar
GW=50         # width of the gauge
GFG='#33ccff'  # color of the gauge
GH=7          # height of the gauge
GBG='#333'    # color of gauge background
X=1770        # x position
Y=1200        # y position
FN='snap'     # font
 
STATEFILE='/proc/acpi/battery/BAT0/state' # battery's state file
INFOFILE='/proc/acpi/battery/BAT0/info'   # battery's info file
 
LOWBAT=25        # percentage of battery life marked as low
LOWCOL='#ff4747' # color when battery is low
CHGCOL='#60da11' # color when battery is charging
TIME_INT=1       # time intervall in seconds
 
PREBAR='^i(/home/webframp/.dzen/icons/dzen_bitmaps/battery.xbm) ' # caption (also icons are possible)
 
while true; do
# look up battery's data
BAT_FULL=`cat $INFOFILE|grep design|line|cut -d " " -f 11`;
STATUS=`cat $STATEFILE|grep charging|cut -d " " -f 12`;
RCAP=`cat $STATEFILE|grep remaining|cut -d " " -f 8`;
 
# calculate remaining power
RPERCT=`expr $RCAP \* 100`;
RPERC=`expr $RPERCT / $BAT_FULL`;
 
# draw the bar and pipe everything into dzen
if [ $RPERC -le $LOWBAT ]; then
GFG=$LOWCOL;
fi
if [ $STATUS = 'charging' ]; then
GFG=$CHGCOL;
else
GFG='#33ccff';
fi
#echo -n $PREBAR #uncomment for an icon
eval echo $RPERC | gdbar -h $GH -w $GW -fg $GFG -bg $GBG
sleep $TIME_INT;
done | dzen2 -ta c -tw $W -y $Y -x $X -fg $FG -bg $BG -fn $FN

Post a Comment

Your email is never published nor shared. Required fields are marked *