Some Handy wmii Odds'n'Sods
I'll get around to adding some useful information here on scripts I have done for wmii, but for now this is all you are getting.
# status buildup
status40() {
if [ -z $(wmiir ls /rbar | grep $1) ]; then
echo "$WMII_NORMCOLORS" | wmiir create /rbar/$1
fi
TEMP=$(cat /sys/devices/platform/coretemp.0/temp1_input)
TEMP=$(($TEMP/1000))
echo -n "TMP: $TEMP°C" | wmiir write /rbar/$1
}
status90() {
if [ -z $(wmiir ls /rbar | grep $1) ]; then
echo "$WMII_NORMCOLORS" | wmiir create /rbar/$1
fi
UPTIME=$(uptime | sed 's/.*://; s/,//g')
echo -n "$UPTIME" | wmiir write /rbar/$1
}
status99() {
if [ -z $(wmiir ls /rbar | grep $1) ]; then
echo "$WMII_NORMCOLORS" | wmiir create /rbar/$1
fi
DATE=$(date +'%a %b %d %H:%M %Z %Y')
echo -n "$DATE" | wmiir write /rbar/$1
}
status30() {
BAR=$(wmiir ls /rbar | grep $1)
if [ ! -d /sys/class/power_supply/CMB1 ]; then
if [ ${#BAR} -ne 0 ]; then
wmiir remove /rbar/$1
fi
return
fi
if [ ${#BAR} -eq 0 ]; then
echo "$WMII_NORMCOLORS" | wmiir create /rbar/$1
fi
REMAIN=$(cat /sys/class/power_supply/CMB1/charge_now)
if [ -z $REMAIN ]; then
echo -n "BAT: <MISSING>" | wmiir write /rbar/$1
fi
STATUS=$(cat /sys/class/power_supply/CMB1/status)
if [ "$STATUS" = "Unknown" -o "$STATUS" = "Not charging" -o "$STATUS" = "Full" ]; then
echo -n "BAT: $(($REMAIN/1000))mAh Charged" | wmiir write /rbar/$1
return
fi
FULL=$(cat /sys/class/power_supply/CMB1/charge_full)
FULL=$((FULL/1000))
# divide by 10 as we have divided FULL by 1000
PCNTREMAIN=$(($REMAIN/$FULL/10))
DRAIN=$(cat /sys/class/power_supply/CMB1/current_now)
PCNTDRAIN=$(($DRAIN/$FULL/10))
if [ "$(cat /sys/class/power_supply/CMB1/status)" = "Charging" ]; then
DIR="+"
else
DIR="-"
fi
echo -n "BAT: ${PCNTREMAIN}%${DIR}${PCNTDRAIN}%/h" | wmiir write /rbar/$1
}
status20() {
BAR=$(wmiir ls /rbar | grep $1)
if [ ! -d /sys/class/net/wlan0 ]; then
if [ ${#BAR} -ne 0 ]; then
wmiir remove /rbar/$1
fi
return
fi
if [ ${#BAR} -eq 0 ]; then
echo "$WMII_NORMCOLORS" | wmiir create /rbar/$1
fi
if [ $(cat /sys/class/net/wlan0/carrier) -eq 0 ]; then
echo -n "WLAN: <NO CARRIER>" | wmiir write /rbar/$1
return
fi
WIFI=$(cat /proc/net/wireless | awk 'BEGIN { FS="[ \t\n.]+" } /wlan0:/ { print $4, $5, $6 }')
SIGNAL=$(echo $WIFI | awk '{ print $2 }')
NOISE=$(echo $WIFI | awk '{ print $3 }')
LEVEL=$((($SIGNAL)-($NOISE)))
SSID=$(/sbin/iwgetid -r wlan0)
RATE=$(/sbin/iwconfig wlan0 | awk 'BEGIN { FS="[= ]+" } /Bit Rate/ { print $4 $5 }')
echo -n "WLAN: $SSID [${LEVEL}dBm @ $RATE]" | wmiir write /rbar/$1
}
status_list="status20 status30 status40 status90 status99"
# Status Bar Info
status() {
while true; do
for f in $status_list; do
eval $f $f init
done
sleep 5
done
}
[snipped]
Action status
set +xv
wmiir ls /rbar | while read bar; do wmiir remove "/rbar/$bar"; done
status
[snipped]