[dev] wmii unicode in the status?

From: Eitan Goldshtrom <thesourceofx_AT_gmail.com>
Date: Sat, 22 Jan 2011 11:28:20 -0500

Hi. I'm trying to print out a progress bar sort of thing that represents
my remaining battery life. I finally got the script to work such that
from a cli I can print out the status as I like it with the correct
information. However, for the bar itself I use unicode block characters.
When it prints to the actual status it ends up printing everything
around the bar fine, but the bar itself is a bunch of wierd characters.
Am I right that that's an indication that the status isn't encoded in
UTF-8? Is there a way to fix that? Below are my status() and the python
script for creating the bar.
-Eitan

Python Script - battbar
#!/usr/bin/python
import math
import sys
r = float(sys.argv[1]) * 16 / 100
i = int(r)
r -= i
output = unichr(9608) * i
j = int(7*r) + 1
if r > 0.0:
   output += unichr(9616-j)
output += " " * (16-i-int(math.ceil(r)))
print output.encode('utf-8')

status() {
     SIGLEV=$(iwconfig wlan0 | grep 'Signal level')
     if [ "$?" = "0" ]; then
         SIGLEV=$(echo -n "$SIGLEV" | sed -n 's:.*Signal level=\(.*
dBm\).*:\1:p')
     else
         SIGLEV=' - '
     fi
     BATT=$(acpi --battery | awk -F ', ' '{print $2}' | sed 's:\(.*\)%:\1:')

     echo -n '<'"$BATT"'%>['$(battbar $BATT)'] wlan0<'"$SIGLEV"'> |'
$(uptime | sed 's/.*://; s/,//g') '|' $(date +'%I:%M.%S %a, %d %b %Y')
}
Received on Sat Jan 22 2011 - 17:28:20 CET

This archive was generated by hypermail 2.2.0 : Sat Jan 22 2011 - 17:36:02 CET