Re: [dev] wmii how to replace status bar with dzen2

From: Thomas Dahms <dahms_AT_ymail.com>
Date: Mon, 07 Feb 2011 12:55:25 +0100

> My reason is that I can use small icons with dzen2 and they can change
> colors. So for example when my battery life goes low then the battery
> icon is turning red.
>
> Probably I could get away with text info instead of icons, but then I
> still need some way of changing the color of given text depending on
> it's value. And I failed to find a way of doing it in wmiirc.

You can do it most easily with the python wmiirc (started with "wmii -r
python/wmiirc"). I defined a function like this in wmiirc.py which changes
color on low battery:

@defmonitor
def battery(self):
     for line in open('/proc/acpi/battery/BAT0/state','r'):
         if len(line.split()) >= 3 and line.split()[0] == 'remaining':
             uebrig = int(line.split()[2])/1000
             struebrig = 'battery {0} Wh'.format(uebrig)
             if uebrig < 10:
                 return wmii.cache['focuscolors'], struebrig
             else:
                 return wmii.cache['normcolors'], struebrig
     return wmii.cache['normcolors'], 'no battery info'

With the sh wmiirc, you can also change color of the status bar, with
something like
wmiir xwrite /rbar/status "color #555555 #ededeb #dcdcdb"

You can only write label (i.e. text) or color at a time, so you have to
modify the "Action status" piece in wmiirc to write both after another.
Note that /rbar/status includes the whole right status bar by default.
Defining another /rbar/battery is probably what you want in order to
change color of only this.

-- 
Thomas Dahms
Received on Mon Feb 07 2011 - 12:55:25 CET

This archive was generated by hypermail 2.2.0 : Mon Feb 07 2011 - 13:00:04 CET