Source obtained from http://sourceforge.net/projects/wmacpi/files/.

2004 August 18 1.99r7
        Implemented the libdockapp port - this seems to close Debian bug
        #227819, but it hasn't received sufficient testing.

        Implemented a capacity mode for calculating time remaining (as
        opposed to the normal current rate mode) - this mode samples the
        remaining capacity of the battery and notes the time at which it
        was sampled, and uses a history of samples to estimate the rate of
        drain on the battery. From there it calculates a value for time
        remaining.

        Also, various cleanups have gone in:

        * a reworking of the scrolling code

        * generic battery number support (rather than just
        using two pixmaps, one for b1 and one for b2)

        * stopped the battery glyph from blinking when running on AC
---
 wmacpi/ChangeLog      |  20 +++
 wmacpi/Makefile       |   2 +-
 wmacpi/acpi.c         |   6 +-
 wmacpi/libacpi.c      | 158 +++++++++++++++++----
 wmacpi/libacpi.h      |  31 ++--
 wmacpi/master.xpm     |  58 ++++----
 wmacpi/master_low.xpm |  56 ++++----
 wmacpi/wmacpi.1       |  18 ++-
 wmacpi/wmacpi.c       | 385 ++++++++++++++++++++++----------------------------
 9 files changed, 410 insertions(+), 324 deletions(-)

diff --git a/wmacpi/ChangeLog b/wmacpi/ChangeLog
index be3fdcd..1a079a1 100644
--- a/wmacpi/ChangeLog
+++ b/wmacpi/ChangeLog
@@ -1,3 +1,23 @@
+2004 August 18 1.99r7
+       Implemented the libdockapp port - this seems to close Debian bug
+       #227819, but it hasn't received sufficient testing.
+
+       Implemented a capacity mode for calculating time remaining (as
+       opposed to the normal current rate mode) - this mode samples the
+       remaining capacity of the battery and notes the time at which it
+       was sampled, and uses a history of samples to estimate the rate of
+       drain on the battery. From there it calculates a value for time
+       remaining. 
+
+       Also, various cleanups have gone in: 
+
+       * a reworking of the scrolling code
+       
+       * generic battery number support (rather than just
+       using two pixmaps, one for b1 and one for b2)
+
+       * stopped the battery glyph from blinking when running on AC
+       
 2004 July 19 1.99r6
        Fix for Debian bug #250792 - the parser for the acpi files was
        too stupid to deal with error conditions. I've now added some
diff --git a/wmacpi/Makefile b/wmacpi/Makefile
index 700e230..4d53ae1 100644
--- a/wmacpi/Makefile
+++ b/wmacpi/Makefile
@@ -14,7 +14,7 @@ BUILD_CLI = 1
 
 CC     := gcc
 CFLAGS := $(OPT) -Wall -W -g -ansi -I/usr/X11R6/include
-LDFLAGS := $(OPT) -L/usr/X11R6/lib -lX11 -lXpm -lXext
+LDFLAGS := $(OPT) -L/usr/X11R6/lib -lX11 -lXpm -lXext -ldockapp
 
 WMSRC  := wmacpi.c libacpi.c
 HEADERS := libacpi.h wmacpi.h
diff --git a/wmacpi/acpi.c b/wmacpi/acpi.c
index 8b748c5..c56b15e 100644
--- a/wmacpi/acpi.c
+++ b/wmacpi/acpi.c
@@ -86,12 +86,12 @@ int main(int argc, char *argv[])
 
        globals = (global_t *) malloc(sizeof(global_t));
 
-       power_init();
+       power_init(globals);
        /* we want to acquire samples over some period of time, so . . . */
        for(i = 0; i < samples + 2; i++) {
                for(j = 0; j < globals->battery_count; j++)
-                       acquire_batt_info(j);
-               acquire_global_info();
+                       acquire_batt_info(globals, j);
+               acquire_global_info(globals);
                usleep(sleep_time);
        }
        
diff --git a/wmacpi/libacpi.c b/wmacpi/libacpi.c
index b888d5f..ac54326 100644
--- a/wmacpi/libacpi.c
+++ b/wmacpi/libacpi.c
@@ -6,17 +6,18 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <dirent.h>
+#include <time.h>
 
 #include "libacpi.h"
 
 extern char *state[];
-extern global_t *globals;
+/* extern global_t *globals; */
 
 /* local proto */
 int acpi_get_design_cap(int batt);
 
 /* initialise the batteries */
-int init_batteries(void)
+int init_batteries(global_t *globals)
 {
     DIR *battdir;
     struct dirent *batt;
@@ -83,16 +84,16 @@ int init_batteries(void)
 }
 
 /* a stub that just calls the current function */
-int reinit_batteries(void)
+int reinit_batteries(global_t *globals)
 {
     pdebug("reinitialising batteries\n");
-    return init_batteries();
+    return init_batteries(globals);
 }
 
 /* the actual name of the subdirectory under ac_adapter may
  * be anything, so we need to read the directory and use the
  * name we find there. */
-int init_ac_adapters(void)
+int init_ac_adapters(global_t *globals)
 {
     DIR *acdir;
     struct dirent *adapter;
@@ -125,14 +126,14 @@ int init_ac_adapters(void)
 }
 
 /* stub that does nothing but call the normal init function */
-int reinit_ac_adapters(void)
+int reinit_ac_adapters(global_t *globals)
 {
     pdebug("reinitialising ac adapters\n");
-    return init_ac_adapters();
+    return init_ac_adapters(globals);
 }
 
 /* see if we have ACPI support and check version */
-int power_init(void)
+int power_init(global_t *globals)
 {
     FILE *acpi;
     char buf[4096];
@@ -156,14 +157,14 @@ int power_init(void)
     /* yep, all good */
     fclose(acpi);
 
-    if (!(retval = init_batteries()))
-       retval = init_ac_adapters();
+    if (!(retval = init_batteries(globals)))
+       retval = init_ac_adapters(globals);
 
     return retval;
 }
 
 /* reinitialise everything, to deal with changing batteries or ac adapters */
-int power_reinit(void)
+int power_reinit(global_t *globals)
 {
     FILE *acpi;
     int retval;
@@ -173,8 +174,8 @@ int power_reinit(void)
        return 1;
     }
     
-    if (!(retval = reinit_batteries()))
-       retval = reinit_ac_adapters();
+    if (!(retval = reinit_batteries(globals)))
+       retval = reinit_ac_adapters(globals);
 
     return retval;
 }
@@ -202,7 +203,7 @@ int check_error(char *buf)
     return 0;
 }
 
-power_state_t get_power_status(void)
+power_state_t get_power_status(global_t *globals)
 {
     FILE *file;
     char buf[1024];
@@ -437,7 +438,7 @@ static int calc_charge_time(int batt)
     return charge_time;
 }
 
-void acquire_batt_info(int batt)
+void acquire_batt_info(global_t *globals, int batt)
 {
     battery_t *binfo;
     adapter_t *ap = &globals->adapter;
@@ -472,7 +473,7 @@ void acquire_batt_info(int batt)
 
     /* we need to /know/ that we've got a valid state for the 
      * globals->power value . . . .*/
-    ap->power = get_power_status();
+    ap->power = get_power_status(globals);
 
     if ((ap->power != AC) && (binfo->charge_state == DISCHARGE)) {
        /* we're not on power, and not charging. So we might as well 
@@ -491,25 +492,44 @@ void acquire_batt_info(int batt)
     binfo->valid = 1;
 }
        
-void acquire_all_batt_info(void)
+void acquire_all_batt_info(global_t *globals)
 {
     int i;
     
     for(i = 0; i < globals->battery_count; i++)
-       acquire_batt_info(i);
+       acquire_batt_info(globals, i);
 }
 
-void acquire_global_info(void)
+/*
+ * One of the feature requests I've had is for some way to deal with
+ * batteries that are too dumb or too b0rken to report a present rate
+ * value. The way to do this, obviously, is to record the time that
+ * samples were taken and use that information to calculate the rate
+ * at which the battery is draining/charging. This still won't help
+ * systems where the battery doesn't even report the remaining
+ * capacity, but without the present rate or the remaining capacity, I
+ * don't think there's /anything/ we can do to work around it.
+ *
+ * So, what we need to do is provide a way to use a different method
+ * to calculate the time remaining. What seems most sensible is to
+ * split out the code to calculate it into a seperate function, and
+ * then provide multiple implementations . . . 
+ */
+
+/*
+ * the default implementation - if present rate and remaining capacity
+ * are both reported correctly, we use them.
+ */
+int calc_time_remaining_rate(global_t *globals)
 {
     int i;
     int rtime;
     float rcap = 0;
     float rate = 0;
     battery_t *binfo;
-    adapter_t *ap = &globals->adapter;
     static float rate_samples[SAMPLES];
-    static int j = 0;
     static int sample_count = 0;
+    static int j = 0;
     static int n = 0;
 
     /* calculate the time remaining, using the battery's remaining 
@@ -529,7 +549,8 @@ void acquire_global_info(void)
     }
     rate_samples[j] = rate;
     j++, sample_count++;
-    j = j % SAMPLES;
+    if (j >= SAMPLES)
+       j = 0;
     
     /* for the first SAMPLES number of calls we calculate the
      * average based on sample_count, then we use SAMPLES to
@@ -562,16 +583,99 @@ void acquire_global_info(void)
        rtime = 0;
  out:
     pdebug("time rem: %d\n", rtime);
-    globals->rtime = rtime;
+    return rtime;
+}
+
+/*
+ * the alternative implementation - record the time at which each
+ * sample was taken, and then use the difference between the latest
+ * sample and the one SAMPLES ago to calculate the difference over
+ * that time, and from there the rate of change of capacity.
+ *
+ * XXX: this code sucks, but largely because batteries aren't exactly
+ * precision instruments - mine only report with about 70mAH
+ * resolution, so they don't report any changes until the difference
+ * is 70mAH. This means that calculating the current rate from the
+ * remaining capacity is very choppy . . . 
+ *
+ * To fix this, we should calculate an average over some number of
+ * samples at the old end of the set - this would smooth out the
+ * transitions. 
+ */
+int calc_time_remaining_cap(global_t *globals)
+{
+    static float cap_samples[SAMPLES];
+    static int time_samples[SAMPLES];
+    static int sample_count = 0;
+    static int current = 0;
+    static int old = 1;
+    battery_t *binfo;
+    int i;
+    int rtime;
+    int tdiff;
+    float cdiff;
+    float cap = 0;
+    float current_rate;
+
+    for (i = 0; i < globals->battery_count; i++) {
+       binfo = &batteries[i];
+       if (binfo->present && binfo->valid)
+           cap += binfo->remaining_cap;
+    }
+    cap_samples[current] = cap;
+    time_samples[current] = time(NULL);
+
+    /* if we have less than SAMPLES samples so far, we use the first
+     * sample and the current one */
+    if (sample_count < SAMPLES) {
+       cdiff = cap_samples[0] - cap_samples[current];
+       tdiff = time_samples[current] - time_samples[0];
+       current_rate = cdiff/tdiff;
+    } else {
+       /* if we have more than SAMPLES samples, we use the oldest
+        * current one, which at this point is current + 1. This will
+        * wrap the same way that current will wrap, but one cycle
+        * ahead */
+       cdiff = cap_samples[old] - cap_samples[current];
+       tdiff = time_samples[current] - time_samples[old];
+       current_rate = cdiff/tdiff;
+    }
+    if (current_rate == 0) 
+       rtime = 0;
+    else
+       rtime = (int)(cap_samples[current]/(current_rate * 60.0));
+
+    sample_count++, current++, old++;
+    if (current >= SAMPLES)
+       current = 0;
+    if (old >= SAMPLES)
+       old = 0;
+
+    pdebug("time rem: %d\n", rtime);
+    return rtime;
+}    
+
+void acquire_global_info(global_t *globals)
+{
+    adapter_t *ap = &globals->adapter;
+
+    switch(globals->rt_mode) {
+    case RT_RATE:
+       globals->rtime = calc_time_remaining_rate(globals);
+       break;
+    case RT_CAP:
+       globals->rtime = calc_time_remaining_cap(globals);
+       break;
+    }
 
     /* get the power status.
      * note that this is actually reported seperately from the
      * battery info, under /proc/acpi/ac_adapter/AC/state */
-    ap->power = get_power_status();
+    ap->power = get_power_status(globals);
 }
 
-void acquire_all_info(void)
+void acquire_all_info(global_t *globals)
 {
-    acquire_all_batt_info();
-    acquire_global_info();
+    acquire_all_batt_info(globals);
+    acquire_global_info(globals);
 }
diff --git a/wmacpi/libacpi.h b/wmacpi/libacpi.h
index 631ef63..b28687a 100644
--- a/wmacpi/libacpi.h
+++ b/wmacpi/libacpi.h
@@ -2,7 +2,7 @@
 #define _LIBACPI_H_
 
 
-#define LIBACPI_VER "0.90"
+#define LIBACPI_VER "0.91"
 
 /* Here because we need it for definitions in this file . . . */
 #define MAX_NAME 128
@@ -71,22 +71,23 @@ typedef struct {
     power_state_t power;
 } adapter_t;
 
+/* how to calculate the time remaining */
+enum rtime_mode {
+    RT_RATE,                   /* using the current rate, as per the ACPI spec 
*/
+    RT_CAP,                    /* using the remaining capacity over time */
+};
+
 typedef struct {
     int rtime;                 /* remaining time */
     int timer;                 /* how long been on battery? */
     int crit_level;            /* anything below this is critical low */
     int battery_count;         /* number of batteries found */
+    enum rtime_mode rt_mode;   
     battery_t *binfo;          /* pointer to the battery being monitored */
     adapter_t adapter;
 } global_t;
 
 /*
- * Note that there are some serious problems with this: firstly, handling of
- * multiple batteries sucks. I've cleaned it up a reasonable amount so far,
- * but I don't know enough about how multiple batteries are handled in the
- * actual power management code to be able to do it right. I need to plug
- * in the second battery for this LifeBook to see how it goes . . .
- *
  * Moving percentage to the battery is right, but I think we need a global
  * remaining capacity somewhere, too . . . 
  */
@@ -124,16 +125,16 @@ battery_t batteries[MAXBATT];
 int verbosity;
 
 /* check if apm/acpi is enabled, etc */
-int power_init(void);
+int power_init(global_t *globals);
 /* reinitialise everything */
-int power_reinit(void);
-int reinit_ac_adapters(void);
-int reinit_batteries(void);
+int power_reinit(global_t *globals);
+int reinit_ac_adapters(global_t *globals);
+int reinit_batteries(global_t *globals);
 
 /* fill global_t with data */
-void acquire_batt_info(int);
-void acquire_all_batt_info(void);
-void acquire_global_info(void);
-void acquire_all_info(void);
+void acquire_batt_info(global_t *globals, int batt);
+void acquire_all_batt_info(global_t *globals);
+void acquire_global_info(global_t *globals);
+void acquire_all_info(global_t *globals);
 
 #endif /* _WMACPI_H_ */
diff --git a/wmacpi/master.xpm b/wmacpi/master.xpm
index ba24bf1..e958772 100644
--- a/wmacpi/master.xpm
+++ b/wmacpi/master.xpm
@@ -99,8 +99,8 @@ static char * master_xpm[] = {
 "@.    c #027E72",
 "#.    c #188A86",
 "$.    c #22B2AE",
-"%.    c #107D79",
-"&.    c #034A40",
+"%.    c #034A40",
+"&.    c #107D79",
 "                                                                              
                                                  .   + @ # $ % & * = - % ; > , 
' % ) ! ~ { % ] ^ / ( % _ : < [ % } | 1 2 % 3 4 5 6 % 7 8 9 0 % a b c d % e f g 
h                                                                           ",
 "                                                                              
                                                  .   + @ # $ % & * = - % ; > , 
' % ) ! ~ { % ] ^ / ( % _ : < [ % } | 1 2 % 3 4 5 6 % 7 8 9 0 % a b c d % e f g 
h                                                                           ",
 "                                                                              
                                                  .   + @ # $ % & * = - % ; > , 
' % ) ! ~ { % ] ^ / ( % _ : < [ % } | 1 2 % 3 4 5 6 % 7 8 9 0 % a b c d % e f g 
h                                                                           ",
@@ -126,7 +126,7 @@ static char * master_xpm[] = {
 "        . % ..% % % % ..........% % % % ..% % % % % % % % ..% % `     . % %  
.%  .% % %  .%  .% % %  .% ..% ..% ..% % `         .   i j k l % m n o p % q r 
s t % u v w x % y z A B % C D E F % G H I J % K L M N % O P Q R % S T U V % W X 
Y Z   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       ",
 "        . % ..% % % % % % % % % % % % % ....................% % `     . % % % 
% %  . . .% % %  . . .% % % % % ..% % % `         .   i j k l % m n o p % q r s 
t % u v w x % y z A B % C D E F % G H I J % K L M N % O P Q R % S T U V % W X Y 
Z   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       ",
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % `     . % % % 
% % % % % % % % % % % % % % % % % % % % `         .   i j k l % m n o p % q r s 
t % u v w x % y z A B % C D E F % G H I J % K L M N % O P Q R % S T U V % W X Y 
Z   % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % `     . % % % 
% % % % % % % % % % % % % % % % % % % % `         .   i j k l % m n o p % q r s 
t % u v w x % y z A B % C D E F % G H I J % K L M N % O P Q R % S T U V % W X Y 
Z   % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %       ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % `     . % % % 
% % % % % % % % % % % % % % % % % % % % `         .   i j k l % m n o p % q r s 
t % u v w x % y z A B % C D E F % G H I J % K L M N % O P Q R % S T U V % W X Y 
Z   % % % % % % % % % % % % % % % % % % % % % % % % % %   % % % % % %       ",
 "        ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `     ` ` ` ` 
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `         .                             
                                                                                
                                                                            ",
 "                                                                              
                                                  .   % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % %                                           ",
 "                                                                              
                                                  .   % % ......% % %  . . .#.% 
#.......#.% #.......#.% #. . . .#.% #.......#.% #.......#.% #.......#.% 
#.......#.% #.......#.% % ..% % % % % % %                                       
    ",
@@ -138,23 +138,23 @@ static char * master_xpm[] = {
 "        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% 
% `     % $.$.$.$.% % %  .% % % %  .% % `         .   % % ......% % %  . . .#.% 
#.......#.% #.......#.% %  . . .#.% #.......#.% #.......#.% %  . . .#.% 
#.......#.% #.......#.% % % % ..% % % #.%                                       
    ",
 "        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% 
% `     % $.% % % $.% %  .% % % %  .% % `         .   % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % %                                           ",
 "        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% 
% `     % $.% % % $.% %  .% % % %  .% % `         .                             
                                                                                
                                                                            ",
-"        . % % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% % 
% `     % $.% % % $.% % %  . . . .% % % `         .   % % % % % % % % % % % % % 
%   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   . . 
. . . . . . . . . . . . . . `   . . . . . . . . . . . . . . . . `           ",
-"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% 
% `     % $.$.$.$.% % %  .% % % %  .% % `         .   % % % % % % ..........% % 
%   % ....................% %   % #.% % ......% % % ......% % % ..% % % %   % % 
% % % % % % % % % % % % % % `   % % % % % % % % % % % % % % % % `           ",
-"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% 
% `     % $.% % % $.% %  .% % % %  .% % `         .   % % % % % ..% % % % 
......%   % ..% % % % % % % % ..% %   % ..% ..% % % ..% ..% % % ..% ..% ..% ..% 
  % % % % % % % % % % % % % % % % `   % % % % % % % % % % % % % % % % `         
  ",
-"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% 
% `     % $.% % % $.% %  .% % % %  .% % `         .   % % % % % ..% % % % ..% % 
%   % ..% % % % % % % % ....%   % ..% ..% % % ..% ..% % % ..% % ..% ..% %   % % 
% % % % % % %  . . . .%.% % `   % % % % % % % % %.........#.% % `           ",
-"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% 
% `     % $.% % % $.% %  .% % % %  .% % `         .   % % % ......% % % % ..% % 
%   % ..% % % % % % % % ....%   % #.% #. . . .#.% #. . . .#.% % % ..% % %   % % 
% % % % % %  .% % % % ..% % `   % % % % % % % %  .% % % % ..% % `           ",
-"        . % % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% % 
% `     % $.$.$.$.% % % %  . . . .% % % `         .   % % ..% % ..% % % % 
......%   % ..% % % % % % % % ....%   % ..% ..% % % ..% ..% % % ..% % ..% ..% % 
  % $.$.$.$.% % %  .% % % % ..% % `   % $.$.$.$.% % %  .% % % % ..% % `         
  ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% `     % % % % % % % % % % % % % % % % `         .   % ..% % % % ..........% % 
%   % ..% % % % % % % % ..% %   % ..% ..% % % ..% ..% % % ..% ..% ..% ..%   % 
$.% % % $.% %  .% % % % ..% % `   % $.% % % $.% %  .% % % % ..% % `           ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% `     % % % % % % % % % % % % % % % % `         .   % ..% % % % % % % % % % % 
%   % ....................% %   % #.% % ......% % % ......% % % % % ..% %   % 
$.% % % $.% %  .% % % % ..% % `   % $.% % % $.% %  .% % % % ..% % `           ",
-"        ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` 
` `     ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `         .   % % % % % % % % % % % % % 
%   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   % 
$.% % % $.% % %  . . . .%.% % `   % $.% % % $.% % %.........%.% % `           ",
-"                                                                              
                                                  .                             
                                                                            % 
$.$.$.$.% % %  .% % % % ..% % `   % $.$.$.$.% % % ..% % % %  .% % `           ",
-"                                                                              
                                                  .   % % % % % % % % % % % % % 
%   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   % 
$.% % % $.% %  .% % % % ..% % `   % $.% % % $.% % ..% % % %  .% % `           ",
-"        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . .         .   % % % % % %  . . . . .% % 
%   %  . . . . . . . . . .% %   % % % %  . . .% % %  . . .% % %  .% % % %   % 
$.% % % $.% %  .% % % % ..% % `   % $.% % % $.% % ..% % % %  .% % `           ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % % % % %  .% % % %  . . 
.%   %  .% % % % % % % %  .% %   %  .%  .% % %  .%  .% % %  .%  .%  .%  .%   % 
$.% % % $.% %  .% % % % ..% % `   % $.% % % $.% % ..% % % %  .% % `           ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % % % % %  .% % % %  .% % 
%   %  .% % % % % % % %  . .%   %  .%  .% % %  .%  .% % %  .% %  .%  .% %   % 
$.$.$.$.% % % %  . . . .%.% % `   % $.$.$.$.% % % %.........%.% % `           ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % % %  . . .% % % %  .% % 
%   %  .% % % % % % % %  . .%   % % % %  . . .% % %  . . .% % % %  .% % %   % % 
% % % % % % % % % % % % % % `   % % % % % % % % % % % % % % % % `           ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % %  .% %  .% % % %  . . 
.%   %  .% % % % % % % %  . .%   %  .%  .% % %  .%  .% % %  .% %  .%  .% %   % 
% % % % % % % % % % % % % % % `   % % % % % % % % % % % % % % % % `           ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   %  .% % % %  . . . . .% % 
%   %  .% % % % % % % %  .% %   %  .%  .% % %  .%  .% % %  .%  .%  .%  .%   ` ` 
` ` ` ` ` ` ` ` ` ` ` ` ` ` `   ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `           ",
+"        . % % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% % 
% `     % $.% % % $.% % %  . . . .% % % `         .   % % % % % % % % % % % % % 
%   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   . . 
. . . . . . . . . . . . . . `                                               ",
+"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% 
% `     % $.$.$.$.% % %  .% % % %  .% % `         .   % % % % % % ..........% % 
%   % ....................% %   % #.% % ......% % % ......% % % ..% % % %   % % 
% % % % % % % % % % % % % % `                                               ",
+"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% 
% `     % $.% % % $.% %  .% % % %  .% % `         .   % % % % % ..% % % % 
......%   % ..% % % % % % % % ..% %   % ..% ..% % % ..% ..% % % ..% ..% ..% ..% 
  % % % % % % % % % % % % % % % % `                                             
  ",
+"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% 
% `     % $.% % % $.% %  .% % % %  .% % `         .   % % % % % ..% % % % ..% % 
%   % ..% % % % % % % % ....%   % ..% ..% % % ..% ..% % % ..% % ..% ..% %   % % 
% % % % % % %  . . . .% % % `                                               ",
+"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% 
% `     % $.% % % $.% %  .% % % %  .% % `         .   % % % ......% % % % ..% % 
%   % ..% % % % % % % % ....%   % #.% #. . . .#.% #. . . .#.% % % ..% % %   % % 
% % % % % %  .% % % %  .% % `                                               ",
+"        . % % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% % 
% `     % $.$.$.$.% % % %  . . . .% % % `         .   % % ..% % ..% % % % 
......%   % ..% % % % % % % % ....%   % ..% ..% % % ..% ..% % % ..% % ..% ..% % 
  % $.$.$.$.% % %  .% % % %  .% % `                                             
  ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% `     % % % % % % % % % % % % % % % % `         .   % ..% % % % ..........% % 
%   % ..% % % % % % % % ..% %   % ..% ..% % % ..% ..% % % ..% ..% ..% ..%   % 
$.% % % $.% %  .% % % %  .% % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% `     % % % % % % % % % % % % % % % % `         .   % ..% % % % % % % % % % % 
%   % ....................% %   % #.% % ......% % % ......% % % % % ..% %   % 
$.% % % $.% %  .% % % %  .% % `                                               ",
+"        ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` 
` `     ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `         .   % % % % % % % % % % % % % 
%   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   % 
$.% % % $.% % %  . . . .% % % `                                               ",
+"                                                                              
                                                  .                             
                                                                            % 
$.$.$.$.% % %  .% % % %  .% % `                                               ",
+"                                                                              
                                                  .   % % % % % % % % % % % % % 
%   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   % 
$.% % % $.% %  .% % % %  .% % `                                               ",
+"        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . .         .   % % % % % %  . . . . .% % 
%   %  . . . . . . . . . .% %   % % % %  . . .% % %  . . .% % %  .% % % %   % 
$.% % % $.% %  .% % % %  .% % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % % % % %  .% % % %  . . 
.%   %  .% % % % % % % %  .% %   %  .%  .% % %  .%  .% % %  .%  .%  .%  .%   % 
$.% % % $.% %  .% % % %  .% % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % % % % %  .% % % %  .% % 
%   %  .% % % % % % % %  . .%   %  .%  .% % %  .%  .% % %  .% %  .%  .% %   % 
$.$.$.$.% % % %  . . . .% % % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % % %  . . .% % % %  .% % 
%   %  .% % % % % % % %  . .%   % % % %  . . .% % %  . . .% % % %  .% % %   % % 
% % % % % % % % % % % % % % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % %  .% %  .% % % %  . . 
.%   %  .% % % % % % % %  . .%   %  .%  .% % %  .%  .% % %  .% %  .%  .% %   % 
% % % % % % % % % % % % % % % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   %  .% % % %  . . . . .% % 
%   %  .% % % % % % % %  .% %   %  .%  .% % %  .%  .% % %  .%  .%  .%  .%   ` ` 
` ` ` ` ` ` ` ` ` ` ` ` ` ` `                                               ",
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   %  .% % % % % % % % % % % 
%   %  . . . . . . . . . .% %   % % % %  . . .% % %  . . .% % % % %  .% %       
                                                                            ",
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % % % % % % % % % % % % % 
%   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %       
                                                                            ",
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .                             
                                                                                
                                                                            ",
@@ -162,30 +162,30 @@ static char * master_xpm[] = {
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % `         .   % % $.$.$.% % % % % % @.% 
@.$.$.$.@.% @.$.$.$.@.% @.% % % @.% @.$.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% 
@.$.$.$.@.% @.$.$.$.@.% % % % % % % % % % % % %   % % % % % %                   
    ",
 "        ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` 
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `         .   % $.% % % $.% % % % % $.% 
% % % % $.% % % % % $.% $.% % % $.% $.% % % % % $.% % % % % % % % % $.% $.% % % 
$.% $.% % % $.% % % % % % % % % % % % %   % % % % % %                       ",
 "                                                                              
                                                  .   % $.% % % $.% % % % % $.% 
% % % % $.% % % % % $.% $.% % % $.% $.% % % % % $.% % % % % % % % % $.% $.% % % 
$.% $.% % % $.% % % % % % % % % % % % %   % % % % % %                       ",
-"                                                                              
                                                  .   % @.% % % @.% % % % % @.% 
@.$.$.$.@.% % $.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% % % % % @.% 
&.$.$.$.&.% @.$.$.$.@.% @.$.$.$.@.% % % % % % %   % % % % % %                   
    ",
+"                                                                              
                                                  .   % @.% % % @.% % % % % @.% 
@.$.$.$.@.% % $.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% % % % % @.% 
%.$.$.$.%.% @.$.$.$.@.% @.$.$.$.@.% % % % % % %   % % % % % %                   
    ",
 "                                                                              
                                                  .   % $.% % % $.% % % % % $.% 
$.% % % % % % % % % $.% % % % % $.% % % % % $.% $.% % % $.% % % % % $.% $.% % % 
$.% % % % % $.% % % % % % % % % % % % %   % % % % % %                       ",
 "                                                                              
                                                  .   % $.% % % $.% % % % % $.% 
$.% % % % % % % % % $.% % % % % $.% % % % % $.% $.% % % $.% % % % % $.% $.% % % 
$.% % % % % $.% % % % % % % % % % % % %   % % % % % %                       ",
 ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . . . . . . . . . .   % % $.$.$.% % % % % % $.% 
@.$.$.$.@.% @.$.$.$.@.% % % % % @.% @.$.$.$.@.% @.$.$.$.@.% % % % % @.% 
@.$.$.$.@.% @.$.$.$.@.% % % % % % % % % % % % %   % % % % $.%                   
    ",
 "                                                                              
                                                      % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % %                                     ",
 "% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % ",
-"% &.$.$.$.&.% @.$.$.$.% % @.$.$.$.@.% @.$.$.$.% % @.$.$.$.@.% @.$.$.$.@.% 
@.$.$.$.@.% @.% % % @.% % % @.% % % % % % % @.% @.% % % @.% @.% % % % % $.% % % 
$.% @.$.$.$.% % @.$.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% 
@.$.$.$.@.% @.% % % @.% @.% % % @.% @.% % % @.% @.% % % @.% @.% % % @.% 
@.$.$.$.@.% ",
+"% %.$.$.$.%.% @.$.$.$.% % @.$.$.$.@.% @.$.$.$.% % @.$.$.$.@.% @.$.$.$.@.% 
@.$.$.$.@.% @.% % % @.% % % @.% % % % % % % @.% @.% % % @.% @.% % % % % $.% % % 
$.% @.$.$.$.% % @.$.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% @.$.$.$.@.% 
@.$.$.$.@.% @.% % % @.% @.% % % @.% @.% % % @.% @.% % % @.% @.% % % @.% 
@.$.$.$.@.% ",
 "% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% 
% % % % $.% % % $.% % % $.% % % % % % % $.% $.% % % $.% $.% % % % % $.$.% $.$.% 
$.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % % % % % $.% 
% % $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% % % % % $.% ",
-"% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% 
% % % % $.% % % $.% % % $.% % % % % % % $.% $.% % $.&.% $.% % % % % $.% $.% $.% 
$.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % % % % % $.% 
% % $.% % % $.% $.% % % $.% $.% % % $.% &.$.% $.&.% $.% % % $.% % % % $.&.% ",
-"% @.$.$.$.@.% @.$.$.$.% % @.% % % % % @.% % % @.% @.$.$.$.% % @.$.$.$.% % 
@.&.$.$.@.% @.$.$.$.@.% % % @.% % % % % % % @.% @.$.$.&.% % @.% % % % % @.% % % 
@.% @.% % % @.% @.% % % @.% @.$.$.$.@.% @.$.% % @.% @.$.$.$.% % @.$.$.$.@.% % % 
@.% % % @.% % % @.% @.% % % @.% @.% % % @.% % &.$.&.% % @.$.$.$.@.% % &.$.&.% % 
",
-"% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% 
% % $.% $.% % % $.% % % $.% % % % % % % $.% $.% % $.&.% $.% % % % % $.% % % $.% 
$.% % % $.% $.% % % $.% $.% % % % % $.% $.% $.% $.% % % $.% % % % % $.% % % $.% 
% % $.% % % $.% $.% % % $.% $.% $.% $.% &.$.% $.&.% % % % % $.% &.$.% % % % ",
+"% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% 
% % % % $.% % % $.% % % $.% % % % % % % $.% $.% % $.%.% $.% % % % % $.% $.% $.% 
$.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % % % % % $.% 
% % $.% % % $.% $.% % % $.% $.% % % $.% %.$.% $.%.% $.% % % $.% % % % $.%.% ",
+"% @.$.$.$.@.% @.$.$.$.% % @.% % % % % @.% % % @.% @.$.$.$.% % @.$.$.$.% % 
@.%.$.$.@.% @.$.$.$.@.% % % @.% % % % % % % @.% @.$.$.%.% % @.% % % % % @.% % % 
@.% @.% % % @.% @.% % % @.% @.$.$.$.@.% @.$.% % @.% @.$.$.$.% % @.$.$.$.@.% % % 
@.% % % @.% % % @.% @.% % % @.% @.% % % @.% % %.$.%.% % @.$.$.$.@.% % %.$.%.% % 
",
+"% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% 
% % $.% $.% % % $.% % % $.% % % % % % % $.% $.% % $.%.% $.% % % % % $.% % % $.% 
$.% % % $.% $.% % % $.% $.% % % % % $.% $.% $.% $.% % % $.% % % % % $.% % % $.% 
% % $.% % % $.% $.% % % $.% $.% $.% $.% %.$.% $.%.% % % % % $.% %.$.% % % % ",
 "% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% 
% % $.% $.% % % $.% % % $.% % % % % % % $.% $.% % % $.% $.% % % % % $.% % % $.% 
$.% % % $.% $.% % % $.% $.% % % % % $.% % $.$.% $.% % % $.% % % % % $.% % % $.% 
% % $.% % % $.% $.% % % $.% $.$.% $.$.% $.% % % $.% % % % % $.% $.% % % % % ",
-"% @.% % % @.% @.$.$.$.% % @.$.$.$.@.% $.$.$.$.% % @.$.$.$.@.% $.% % % % % 
@.$.$.$.@.% @.% % % @.% % % $.% % % @.$.$.$.@.% @.% % % @.% @.$.$.$.&.% @.% % % 
@.% $.% % % $.% @.$.$.$.@.% @.% % % % % @.$.$.$.@.% @.% % % @.% @.$.$.$.@.% % % 
@.% % % &.$.$.$.$.% % $.$.$.% % $.% % % $.% @.% % % $.% @.$.$.$.@.% @.$.$.$.@.% 
",
+"% @.% % % @.% @.$.$.$.% % @.$.$.$.@.% $.$.$.$.% % @.$.$.$.@.% $.% % % % % 
@.$.$.$.@.% @.% % % @.% % % $.% % % @.$.$.$.@.% @.% % % @.% @.$.$.$.%.% @.% % % 
@.% $.% % % $.% @.$.$.$.@.% @.% % % % % @.$.$.$.@.% @.% % % @.% @.$.$.$.@.% % % 
@.% % % %.$.$.$.$.% % $.$.$.% % $.% % % $.% @.% % % $.% @.$.$.$.@.% @.$.$.$.@.% 
",
 "% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % ",
 "% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %         
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %   % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % %       % % % % % % % % ",
-"% % ........% % %  . . . .%.% %.........#.% %.........%.% %. . . . .%.% 
%.........%.% %.........#.% %.........%.% %.........#.% %.........#.% % % % %   
      % % ........% % % ........% % % % % % % ........% % % ........% %   % %  
. . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % % $. . . 
.$.% ",
+"% % ........% % %  . . . .&.% &.........#.% &.........&.% &. . . . .&.% 
&.........&.% &.........#.% &.........&.% &.........#.% &.........#.% % % % %   
      % % ........% % % ........% % % % % % % ........% % % ........% %   % %  
. . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % % $. . . 
.$.% ",
 "% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % 
% %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % ..% %         
% ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % % 
 .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       % $.% $.% $. .% ",
 "% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % 
% %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % ..% %         
% ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % % 
 .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       %  .$.% $.%  .% ",
 "% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % 
% %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % % % %         
% ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % % 
 .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       %  .% $.% $. .% ",
 "% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % 
% %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % % % %         
% ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % % 
 .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       %  .$.% $.% $.% ",
-"% %. . . . .%.% %  . . . .%.% %.........%.% %.........%.% %.........%.% 
%.........%.% %.........%.% %  . . . .%.% %.........%.% %.........%.% % % % %   
      % %. . . . .%.% %. . . . .%.% % % % % %. . . . .%.% %. . . . .%.%   % %  
. . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % $. . . 
.$.% % ",
+"% &. . . . .&.% %  . . . .&.% &.........&.% &.........&.% &.........&.% 
&.........&.% &.........&.% %  . . . .&.% &.........&.% &.........&.% % % % %   
      % &. . . . .&.% &. . . . .&.% % % % % &. . . . .&.% &. . . . .&.%   % %  
. . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % $. . . 
.$.% % ",
 "% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % 
% % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % % % %         
% ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % % 
 .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       %  .% % % %  .% ",
 "% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % 
% % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % % % %         
% ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % % 
 .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       % $.$.$.$.$. .% ",
 "% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % 
% % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % ..% %         
% ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % % 
 .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       % $.% % % $.$.% ",
 "% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % 
% % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % ..% %         
% ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % % 
 .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       % $.% % % $.$.% ",
-"% % ........% % %  . . . .%.% %.........%.% %.........%.% %  . . . .%.% 
%.........%.% %.........%.% %  . . . .%.% %.........%.% %.........%.% % % % %   
      % % ........% % % ........% % % % % % % ........% % % ........% %   % %  
. . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % 
$.$.$.$.$.% % ",
+"% % ........% % %  . . . .&.% &.........&.% &.........&.% %  . . . .&.% 
&.........&.% &.........&.% %  . . . .&.% &.........&.% &.........&.% % % % %   
      % % ........% % % ........% % % % % % % ........% % % ........% %   % %  
. . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % 
$.$.$.$.$.% % ",
 "% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %         
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %   % % % % % % 
% % % % % % % % % % % % % % % % % % % % % % % % % % %       % % % % % % % % "};
diff --git a/wmacpi/master_low.xpm b/wmacpi/master_low.xpm
index cbb21ed..1d91d52 100644
--- a/wmacpi/master_low.xpm
+++ b/wmacpi/master_low.xpm
@@ -17,8 +17,8 @@ static char * master_low_xpm[] = {
 ",     c #188A86",
 "'     c #22B2AE",
 ")     c #C7C7C7",
-"!     c #107D79",
-"~     c #034A40",
+"!     c #034A40",
+"~     c #107D79",
 "                                                                . 
++++@++++@++++@####@####@####@####@$$$$@$$$$@$$$$@$$$$                          
           ",
 "                                                                . 
++++@++++@++++@####@####@####@####@$$$$@$$$$@$$$$@$$$$                          
           ",
 "                                                                . 
++++@++++@++++@####@####@####@####@$$$$@$$$$@$$$$@$$$$                          
           ",
@@ -56,23 +56,23 @@ static char * master_low_xpm[] = {
 "    .@@-@@@@-@-@@@@-@@-@@-@@@@-@-@@@@-@@=  @''''@@@-@@@@-@@=    . 
@@;;;@@@---,@,;;;,@,;;;,@@---,@,;;;,@,;;;,@@---,@,;;;,@,;;;,@@@@;@@@,@          
           ",
 "    .@@-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@@=  @'@@@'@@-@@@@-@@=    . 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@          
           ",
 "    .@@-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@@=  @'@@@'@@-@@@@-@@=    .             
                                                                               
",
-"    .@@@----@@@----@@@@@@@----@@@----@@@=  @'@@@'@@@----@@@=    . 
@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@ ................) 
................)     ",
-"    .@@-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@@=  @''''@@@-@@@@-@@=    . 
@@@@@@;;;;;@@@ @;;;;;;;;;;@@ @,@@;;;@@@;;;@@@;@@@@ @@@@@@@@@@@@@@@@) 
@@@@@@@@@@@@@@@@)     ",
-"    .@@-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@@=  @'@@@'@@-@@@@-@@=    . 
@@@@@;@@@@;;;@ @;@@@@@@@@;@@ @;@;@@@;@;@@@;@;@;@;@ @@@@@@@@@@@@@@@@) 
@@@@@@@@@@@@@@@@)     ",
-"    .@@-@@@@-@-@@@@-@@-@@-@@@@-@-@@@@-@@=  @'@@@'@@-@@@@-@@=    . 
@@@@@;@@@@;@@@ @;@@@@@@@@;;@ @;@;@@@;@;@@@;@@;@;@@ @@@@@@@@@----!@@) 
@@@@@@@@!;;;;,@@)     ",
-"    .@@-@@@@-@-@@@@-@@-@@-@@@@-@-@@@@-@@=  @'@@@'@@-@@@@-@@=    . 
@@@;;;@@@@;@@@ @;@@@@@@@@;;@ @,@,---,@,---,@@@;@@@ @@@@@@@@-@@@@;@@) 
@@@@@@@@-@@@@;@@)     ",
-"    .@@@----@@@----@@@@@@@----@@@----@@@=  @''''@@@@----@@@=    . 
@@;@@;@@@@;;;@ @;@@@@@@@@;;@ @;@;@@@;@;@@@;@@;@;@@ @''''@@@-@@@@;@@) 
@''''@@@-@@@@;@@)     ",
-"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=  @@@@@@@@@@@@@@@@=    . 
@;@@@@;;;;;@@@ @;@@@@@@@@;@@ @;@;@@@;@;@@@;@;@;@;@ @'@@@'@@-@@@@;@@) 
@'@@@'@@-@@@@;@@)     ",
-"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=  @@@@@@@@@@@@@@@@=    . 
@;@@@@@@@@@@@@ @;;;;;;;;;;@@ @,@@;;;@@@;;;@@@@@;@@ @'@@@'@@-@@@@;@@) 
@'@@@'@@-@@@@;@@)     ",
-"    =====================================  =================    . 
@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@ @'@@@'@@@----!@@) 
@'@@@'@@!;;;;!@@)     ",
-"                                                                .             
                                       @''''@@@-@@@@;@@) @''''@@@;@@@@-@@)     
",
-"                                                                . 
@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@ @'@@@'@@-@@@@;@@) 
@'@@@'@@;@@@@-@@)     ",
-"    ........................................................    . 
@@@@@@-----@@@ @----------@@ @@@@---@@@---@@@-@@@@ @'@@@'@@-@@@@;@@) 
@'@@@'@@;@@@@-@@)     ",
-"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@@@@-@@@@---@ @-@@@@@@@@-@@ @-@-@@@-@-@@@-@-@-@-@ @'@@@'@@-@@@@;@@) 
@'@@@'@@;@@@@-@@)     ",
-"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@@@@-@@@@-@@@ @-@@@@@@@@--@ @-@-@@@-@-@@@-@@-@-@@ @''''@@@@----!@@) 
@''''@@@!;;;;!@@)     ",
-"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@@---@@@@-@@@ @-@@@@@@@@--@ @@@@---@@@---@@@@-@@@ @@@@@@@@@@@@@@@@) 
@@@@@@@@@@@@@@@@)     ",
-"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@-@@-@@@@---@ @-@@@@@@@@--@ @-@-@@@-@-@@@-@@-@-@@ @@@@@@@@@@@@@@@@) 
@@@@@@@@@@@@@@@@)     ",
-"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@-@@@@-----@@@ @-@@@@@@@@-@@ @-@-@@@-@-@@@-@-@-@-@ ))))))))))))))))) 
)))))))))))))))))     ",
+"    .@@@----@@@----@@@@@@@----@@@----@@@=  @'@@@'@@@----@@@=    . 
@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@ ................)            
           ",
+"    .@@-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@@=  @''''@@@-@@@@-@@=    . 
@@@@@@;;;;;@@@ @;;;;;;;;;;@@ @,@@;;;@@@;;;@@@;@@@@ @@@@@@@@@@@@@@@@)            
           ",
+"    .@@-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@@=  @'@@@'@@-@@@@-@@=    . 
@@@@@;@@@@;;;@ @;@@@@@@@@;@@ @;@;@@@;@;@@@;@;@;@;@ @@@@@@@@@@@@@@@@)            
           ",
+"    .@@-@@@@-@-@@@@-@@-@@-@@@@-@-@@@@-@@=  @'@@@'@@-@@@@-@@=    . 
@@@@@;@@@@;@@@ @;@@@@@@@@;;@ @;@;@@@;@;@@@;@@;@;@@ @@@@@@@@@----@@@)            
           ",
+"    .@@-@@@@-@-@@@@-@@-@@-@@@@-@-@@@@-@@=  @'@@@'@@-@@@@-@@=    . 
@@@;;;@@@@;@@@ @;@@@@@@@@;;@ @,@,---,@,---,@@@;@@@ @@@@@@@@-@@@@-@@)            
           ",
+"    .@@@----@@@----@@@@@@@----@@@----@@@=  @''''@@@@----@@@=    . 
@@;@@;@@@@;;;@ @;@@@@@@@@;;@ @;@;@@@;@;@@@;@@;@;@@ @''''@@@-@@@@-@@)            
           ",
+"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=  @@@@@@@@@@@@@@@@=    . 
@;@@@@;;;;;@@@ @;@@@@@@@@;@@ @;@;@@@;@;@@@;@;@;@;@ @'@@@'@@-@@@@-@@)            
           ",
+"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=  @@@@@@@@@@@@@@@@=    . 
@;@@@@@@@@@@@@ @;;;;;;;;;;@@ @,@@;;;@@@;;;@@@@@;@@ @'@@@'@@-@@@@-@@)            
           ",
+"    =====================================  =================    . 
@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@ @'@@@'@@@----@@@)            
           ",
+"                                                                .             
                                       @''''@@@-@@@@-@@)                       
",
+"                                                                . 
@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@ @'@@@'@@-@@@@-@@)            
           ",
+"    ........................................................    . 
@@@@@@-----@@@ @----------@@ @@@@---@@@---@@@-@@@@ @'@@@'@@-@@@@-@@)            
           ",
+"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@@@@-@@@@---@ @-@@@@@@@@-@@ @-@-@@@-@-@@@-@-@-@-@ @'@@@'@@-@@@@-@@)            
           ",
+"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@@@@-@@@@-@@@ @-@@@@@@@@--@ @-@-@@@-@-@@@-@@-@-@@ @''''@@@@----@@@)            
           ",
+"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@@---@@@@-@@@ @-@@@@@@@@--@ @@@@---@@@---@@@@-@@@ @@@@@@@@@@@@@@@@)            
           ",
+"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@-@@-@@@@---@ @-@@@@@@@@--@ @-@-@@@-@-@@@-@@-@-@@ @@@@@@@@@@@@@@@@)            
           ",
+"    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@-@@@@-----@@@ @-@@@@@@@@-@@ @-@-@@@-@-@@@-@-@-@-@ )))))))))))))))))            
           ",
 "    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@-@@@@@@@@@@@@ @----------@@ @@@@---@@@---@@@@@-@@                              
           ",
 "    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@                              
           ",
 "    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    .             
                                                                               
",
@@ -80,30 +80,30 @@ static char * master_low_xpm[] = {
 "    .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=    . 
@@'''@@@@@@>@>'''>@>'''>@>@@@>@>'''>@>'''>@>'''>@>'''>@>'''>@@@@@@@@@@@@@ 
@@@@@@           ",
 "    ========================================================    . 
@'@@@'@@@@@'@@@@@'@@@@@'@'@@@'@'@@@@@'@@@@@@@@@'@'@@@'@'@@@'@@@@@@@@@@@@@ 
@@@@@@           ",
 "                                                                . 
@'@@@'@@@@@'@@@@@'@@@@@'@'@@@'@'@@@@@'@@@@@@@@@'@'@@@'@'@@@'@@@@@@@@@@@@@ 
@@@@@@           ",
-"                                                                . 
@>@@@>@@@@@>@>'''>@@'''>@>'''>@>'''>@>'''>@@@@@>@~'''~@>'''>@>'''>@@@@@@@ 
@@@@@@           ",
+"                                                                . 
@>@@@>@@@@@>@>'''>@@'''>@>'''>@>'''>@>'''>@@@@@>@!'''!@>'''>@>'''>@@@@@@@ 
@@@@@@           ",
 "                                                                . 
@'@@@'@@@@@'@'@@@@@@@@@'@@@@@'@@@@@'@'@@@'@@@@@'@'@@@'@@@@@'@@@@@@@@@@@@@ 
@@@@@@           ",
 "                                                                . 
@'@@@'@@@@@'@'@@@@@@@@@'@@@@@'@@@@@'@'@@@'@@@@@'@'@@@'@@@@@'@@@@@@@@@@@@@ 
@@@@@@           ",
 "................................................................. 
@@'''@@@@@@'@>'''>@>'''>@@@@@>@>'''>@>'''>@@@@@>@>'''>@>'''>@@@@@@@@@@@@@ 
@@@@'@           ",
 "                                                                  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@       
           ",
 
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@",
-"@~'''~@>'''@@>'''>@>'''@@>'''>@>'''>@>'''>@>@@@>@@@>@@@@@@@>@>@@@>@>@@@@@'@@@'@>'''@@>'''>@>'''>@>'''>@>'''>@>'''>@>'''>@>@@@>@>@@@>@>@@@>@>@@@>@>@@@>@>'''>@",
+"@!'''!@>'''@@>'''>@>'''@@>'''>@>'''>@>'''>@>@@@>@@@>@@@@@@@>@>@@@>@>@@@@@'@@@'@>'''@@>'''>@>'''>@>'''>@>'''>@>'''>@>'''>@>@@@>@>@@@>@>@@@>@>@@@>@>@@@>@>'''>@",
 
"@'@@@'@'@@@'@'@@@@@'@@@'@'@@@@@'@@@@@'@@@@@'@@@'@@@'@@@@@@@'@'@@@'@'@@@@@''@''@'@@@'@'@@@'@'@@@'@'@@@'@'@@@'@'@@@@@@@'@@@'@@@'@'@@@'@'@@@'@'@@@'@'@@@'@@@@@'@",
-"@'@@@'@'@@@'@'@@@@@'@@@'@'@@@@@'@@@@@'@@@@@'@@@'@@@'@@@@@@@'@'@@'~@'@@@@@'@'@'@'@@@'@'@@@'@'@@@'@'@@@'@'@@@'@'@@@@@@@'@@@'@@@'@'@@@'@'@@@'@~'@'~@'@@@'@@@@'~@",
-"@>'''>@>'''@@>@@@@@>@@@>@>'''@@>'''@@>~''>@>'''>@@@>@@@@@@@>@>''~@@>@@@@@>@@@>@>@@@>@>@@@>@>'''>@>'@@>@>'''@@>'''>@@@>@@@>@@@>@>@@@>@>@@@>@@~'~@@>'''>@@~'~@@",
-"@'@@@'@'@@@'@'@@@@@'@@@'@'@@@@@'@@@@@'@@@'@'@@@'@@@'@@@@@@@'@'@@'~@'@@@@@'@@@'@'@@@'@'@@@'@'@@@@@'@'@'@'@@@'@@@@@'@@@'@@@'@@@'@'@@@'@'@'@'@~'@'~@@@@@'@~'@@@@",
+"@'@@@'@'@@@'@'@@@@@'@@@'@'@@@@@'@@@@@'@@@@@'@@@'@@@'@@@@@@@'@'@@'!@'@@@@@'@'@'@'@@@'@'@@@'@'@@@'@'@@@'@'@@@'@'@@@@@@@'@@@'@@@'@'@@@'@'@@@'@!'@'!@'@@@'@@@@'!@",
+"@>'''>@>'''@@>@@@@@>@@@>@>'''@@>'''@@>!''>@>'''>@@@>@@@@@@@>@>''!@@>@@@@@>@@@>@>@@@>@>@@@>@>'''>@>'@@>@>'''@@>'''>@@@>@@@>@@@>@>@@@>@>@@@>@@!'!@@>'''>@@!'!@@",
+"@'@@@'@'@@@'@'@@@@@'@@@'@'@@@@@'@@@@@'@@@'@'@@@'@@@'@@@@@@@'@'@@'!@'@@@@@'@@@'@'@@@'@'@@@'@'@@@@@'@'@'@'@@@'@@@@@'@@@'@@@'@@@'@'@@@'@'@'@'@!'@'!@@@@@'@!'@@@@",
 
"@'@@@'@'@@@'@'@@@@@'@@@'@'@@@@@'@@@@@'@@@'@'@@@'@@@'@@@@@@@'@'@@@'@'@@@@@'@@@'@'@@@'@'@@@'@'@@@@@'@@''@'@@@'@@@@@'@@@'@@@'@@@'@'@@@'@''@''@'@@@'@@@@@'@'@@@@@",
-"@>@@@>@>'''@@>'''>@''''@@>'''>@'@@@@@>'''>@>@@@>@@@'@@@>'''>@>@@@>@>'''~@>@@@>@'@@@'@>'''>@>@@@@@>'''>@>@@@>@>'''>@@@>@@@~''''@@'''@@'@@@'@>@@@'@>'''>@>'''>@",
+"@>@@@>@>'''@@>'''>@''''@@>'''>@'@@@@@>'''>@>@@@>@@@'@@@>'''>@>@@@>@>'''!@>@@@>@'@@@'@>'''>@>@@@@@>'''>@>@@@>@>'''>@@@>@@@!''''@@'''@@'@@@'@>@@@'@>'''>@>'''>@",
 
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@",
 "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
@@@@@@@@",
-"@@;;;;@@@----!@!;;;;,@!;;;;!@!----!@!;;;;!@!;;;;,@!;;;;!@!;;;;,@!;;;;,@@@@@   
 @@;;;;@@@;;;;@@@@@@@;;;;@@@;;;;@@ @@----@@@----@@@@@@@----@@@----@@   
@@'---'@",
+"@@;;;;@@@----~@~;;;;,@~;;;;~@~----~@~;;;;~@~;;;;,@~;;;;~@~;;;;,@~;;;;,@@@@@   
 @@;;;;@@@;;;;@@@@@@@;;;;@@@;;;;@@ @@----@@@----@@@@@@@----@@@----@@   
@@'---'@",
 "@;@@@@;@-@@@@;@-@@@@;@-@@@@;@;@@@@;@;@@@@-@;@@@@-@-@@@@;@;@@@@;@;@@@@;@@;@@   
 @;@@@@;@;@@@@;@@;@@;@@@@;@;@@@@;@ @-@@@@-@-@@@@-@@-@@-@@@@-@-@@@@-@   
@'@'@'-@",
 "@;@@@@;@-@@@@;@-@@@@;@-@@@@;@;@@@@;@;@@@@-@;@@@@-@-@@@@;@;@@@@;@;@@@@;@@;@@   
 @;@@@@;@;@@@@;@@;@@;@@@@;@;@@@@;@ @-@@@@-@-@@@@-@@-@@-@@@@-@-@@@@-@   
@-'@'@-@",
 "@;@@@@;@-@@@@;@-@@@@;@-@@@@;@;@@@@;@;@@@@-@;@@@@-@-@@@@;@;@@@@;@;@@@@;@@@@@   
 @;@@@@;@;@@@@;@@@@@;@@@@;@;@@@@;@ @-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@   
@-@'@'-@",
 "@;@@@@;@-@@@@;@-@@@@;@-@@@@;@;@@@@;@;@@@@-@;@@@@-@-@@@@;@;@@@@;@;@@@@;@@@@@   
 @;@@@@;@;@@@@;@@@@@;@@@@;@;@@@@;@ @-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@   
@-'@'@'@",
-"@!----!@@----!@!;;;;!@!;;;;!@!;;;;!@!;;;;!@!;;;;!@@----!@!;;;;!@!;;;;!@@@@@   
 @!----!@!----!@@@@@!----!@!----!@ @@----@@@----@@@@@@@----@@@----@@   
@'---'@@",
+"@~----~@@----~@~;;;;~@~;;;;~@~;;;;~@~;;;;~@~;;;;~@@----~@~;;;;~@~;;;;~@@@@@   
 @~----~@~----~@@@@@~----~@~----~@ @@----@@@----@@@@@@@----@@@----@@   
@'---'@@",
 "@;@@@@;@-@@@@;@;@@@@-@-@@@@;@-@@@@;@-@@@@;@;@@@@;@-@@@@;@;@@@@;@-@@@@;@@@@@   
 @;@@@@;@;@@@@;@@@@@;@@@@;@;@@@@;@ @-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@   
@-@@@@-@",
 "@;@@@@;@-@@@@;@;@@@@-@-@@@@;@-@@@@;@-@@@@;@;@@@@;@-@@@@;@;@@@@;@-@@@@;@@@@@   
 @;@@@@;@;@@@@;@@@@@;@@@@;@;@@@@;@ @-@@@@-@-@@@@-@@@@@-@@@@-@-@@@@-@   
@'''''-@",
 "@;@@@@;@-@@@@;@;@@@@-@-@@@@;@-@@@@;@-@@@@;@;@@@@;@-@@@@;@;@@@@;@-@@@@;@@;@@   
 @;@@@@;@;@@@@;@@;@@;@@@@;@;@@@@;@ @-@@@@-@-@@@@-@@-@@-@@@@-@-@@@@-@   
@'@@@''@",
 "@;@@@@;@-@@@@;@;@@@@-@-@@@@;@-@@@@;@-@@@@;@;@@@@;@-@@@@;@;@@@@;@-@@@@;@@;@@   
 @;@@@@;@;@@@@;@@;@@;@@@@;@;@@@@;@ @-@@@@-@-@@@@-@@-@@-@@@@-@-@@@@-@   
@'@@@''@",
-"@@;;;;@@@----!@!;;;;!@!;;;;!@@----!@!;;;;!@!;;;;!@@----!@!;;;;!@!;;;;!@@@@@   
 @@;;;;@@@;;;;@@@@@@@;;;;@@@;;;;@@ @@----@@@----@@@@@@@----@@@----@@   
@'''''@@",
+"@@;;;;@@@----~@~;;;;~@~;;;;~@@----~@~;;;;~@~;;;;~@@----~@~;;;;~@~;;;;~@@@@@   
 @@;;;;@@@;;;;@@@@@@@;;;;@@@;;;;@@ @@----@@@----@@@@@@@----@@@----@@   
@'''''@@",
 "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
@@@@@@@@"};
diff --git a/wmacpi/wmacpi.1 b/wmacpi/wmacpi.1
index 381587b..304a423 100644
--- a/wmacpi/wmacpi.1
+++ b/wmacpi/wmacpi.1
@@ -18,9 +18,12 @@ battery no ]
 .RI -s
 sample rate ]
 [
-.RI -v
+.RI -f
 ]
+[
+.RI -v
 ]
+[
 .RI -n
 ]
 [
@@ -99,6 +102,17 @@ minute. Minimum is 1, ie once a minute, default is 20, 
maximum is 600.
 Disable blinking power glyph when charging. Note that it still blinks when 
 the battery reports its capacity state as critical.
 .TP
+.B \-f
+Force the use of capacity mode for calculating time remaining. By defalt
+.B wmacpi
+will use the reported values of remaining capacity and present rate to
+calculate the time remaining on battery. This flag will force the use
+of the remaining capacity and time samples to calculate the present
+rate of drain, and from there the time remaining. Note that this mode
+of calculation generally underreports the time remaining. This mode
+works around certain buggy ACPI BIOSes that fail to report the current
+rate.
+.TP
 .B \-w
 Run wmacpi in command line mode - this operates identically to 
 .B acpi
@@ -152,4 +166,4 @@ This manual page was originally written by Simon Richter
 <s...@debian.org> for the Debian GNU/Linux system, and then updated by
 Simon Fowler. 
 .br
-Last modification by Simon Fowler <si...@dreamcraft.com.au>, 2004-04-15.
+Last modification by Simon Fowler <si...@dreamcraft.com.au>, 2004-08-15.
diff --git a/wmacpi/wmacpi.c b/wmacpi/wmacpi.c
index abde0d3..3473541 100644
--- a/wmacpi/wmacpi.c
+++ b/wmacpi/wmacpi.c
@@ -18,6 +18,8 @@
 
 #define _GNU_SOURCE
 
+#include <dockapp.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -35,56 +37,48 @@
 #include "libacpi.h"
 #include "wmacpi.h"
 
-#define WMACPI_VER "1.99r6"
+#define WMACPI_VER "1.99r7"
 
 /* main pixmap */
 #ifdef LOW_COLOR
 #include "master_low.xpm"
+static char **master_xpm = master_low_xpm;
 #else
 #include "master.xpm"
 #endif
 
-typedef struct {
-    Display *display;          /* X11 display struct */
-    int screen;                        /* current screen */
-    Window root;               /* root window */
-    Window win;                        /* one window */
-    Window iconwin;            /* another one */
-    Pixmap pixmap;             /* UI pixmap, window pixmap */
-    Pixmap mask;               /* mask pixmap for shape */
-    GC gc;                     /* main drawing GC */
+struct dockapp {
+    Display *display;          /* display */
+    Window win;                        /* main window */
+    Pixmap pixmap;             /* main pixmap */
+    Pixmap mask;               /* mask pixmap */
     Pixmap text;               /* pixmap for text scroller */
+    unsigned width;            /* width of pixmap */
+    unsigned height;           /* height of pixmap */
+    int screen;                        /* current screen */
     int tw;                    /* text width inside text pixmap */
     int update;                        /* need to redraw? */
     int blink;                 /* should we blink the LED? (critical battery) 
*/
     int bell;                  /* bell on critical low, or not? */
     int scroll;                        /* scroll message text? */
     int scroll_reset;          /* reset the scrolling text */
-} Dockapp;
+};
 
 /* globals */
-Dockapp *dockapp;
-global_t *globals;
+struct dockapp *dockapp;
+/* global_t *globals; */
 
 /* this gives us a variable scroll rate, depending on the importance of the
  * message . . . */
 #define DEFAULT_SCROLL_RESET 150;
 int scroll_reset = DEFAULT_SCROLL_RESET;
 
-/* proto for local stuff */
-static void new_window(char *name);
-static int open_display(char *display);
-static void redraw_window(void);
-static void render_text(char *string);
-static void scroll_text(void);
-static void display_percentage(int percent);
-static void display_time(int minutes);
-
-#define copy_xpm_area(x, y, w, h, dx, dy)                              \
-{                                                                      \
-    XCopyArea(dockapp->display, dockapp->pixmap, dockapp->pixmap,      \
-           dockapp->gc, x, y, w, h, dx, dy);                           \
-    dockapp->update = 1;                                               \
+/* copy a chunk of pixmap around the app */
+static void copy_xpm_area(int x, int y, int w, int h, int dx, int dy)          
                        
+{                                                                              
+    XCopyArea(DADisplay, dockapp->pixmap, dockapp->pixmap,     
+             DAGC, x, y, w, h, dx, dy);                        
+    dockapp->update = 1;                                                       
 }
 
 /* display AC power symbol */
@@ -127,77 +121,35 @@ static void reset_scroll(void) {
     dockapp->scroll_reset = 1;
 }
 
+static void clear_text_area(void) {
+    copy_xpm_area(66, 9, 52, 7, 6, 50);
+}
+
 static void redraw_window(void)
 {
     if (dockapp->update) {
-       XCopyArea(dockapp->display, dockapp->pixmap, dockapp->iconwin,
-                 dockapp->gc, 0, 0, 64, 64, 0, 0);
        XCopyArea(dockapp->display, dockapp->pixmap, dockapp->win,
-                 dockapp->gc, 0, 0, 64, 64, 0, 0);
+                 DAGC, 0, 0, 64, 64, 0, 0);
        dockapp->update = 0;
     }
 }
 
-static void new_window(char *name)
+static void new_window(char *display, char *name, int argc, char **argv)
 {
-    XpmAttributes attr;
-    Pixel fg, bg;
-    XGCValues gcval;
-    XSizeHints sizehints;
-    XClassHint classhint;
-    XWMHints wmhints;
-
-    dockapp->screen = DefaultScreen(dockapp->display);
-    dockapp->root = DefaultRootWindow(dockapp->display);
-
-    sizehints.flags = USSize | USPosition;
-    sizehints.width = 64;
-    sizehints.height = 64;
-
-    fg = BlackPixel(dockapp->display, dockapp->screen);
-    bg = WhitePixel(dockapp->display, dockapp->screen);
-
-    dockapp->win = XCreateSimpleWindow(dockapp->display, dockapp->root,
-                                      0, 0, sizehints.width,
-                                      sizehints.height, 1, fg, bg);
-    dockapp->iconwin =
-       XCreateSimpleWindow(dockapp->display, dockapp->win, 0, 0,
-                           sizehints.width, sizehints.height, 1, fg, bg);
-
-    XSetWMNormalHints(dockapp->display, dockapp->win, &sizehints);
-    classhint.res_name = name;
-    classhint.res_class = name;
-    XSetClassHint(dockapp->display, dockapp->win, &classhint);
+    /* Initialise the dockapp window and appicon */
+    DAInitialize(display, name, 64, 64, argc, argv);
+    dockapp->display = DADisplay;
+    dockapp->win = DAWindow;
 
     XSelectInput(dockapp->display, dockapp->win,
-                ExposureMask | ButtonPressMask | ButtonReleaseMask |
-                StructureNotifyMask);
-    XSelectInput(dockapp->display, dockapp->iconwin,
-                ExposureMask | ButtonPressMask | ButtonReleaseMask |
-                StructureNotifyMask);
-
-    XStoreName(dockapp->display, dockapp->win, name);
-    XSetIconName(dockapp->display, dockapp->win, name);
-
-    gcval.foreground = fg;
-    gcval.background = bg;
-    gcval.graphics_exposures = False;
-
-    dockapp->gc =
-       XCreateGC(dockapp->display, dockapp->win,
-                 GCForeground | GCBackground | GCGraphicsExposures,
-                 &gcval);
-
-    attr.exactColors = 0;
-    attr.alloc_close_colors = 1;
-    attr.closeness = 1L << 15;
-    attr.valuemask = XpmExactColors | XpmAllocCloseColors | XpmCloseness;
-    if (XpmCreatePixmapFromData(dockapp->display, dockapp->win,
-                               master_xpm, &dockapp->pixmap,
-                               &dockapp->mask, &attr) != XpmSuccess) {
-       pfatal("FATAL: Not enough colors for main pixmap!\n");
-       exit(1);
-    }
+                 ExposureMask | ButtonPressMask | ButtonReleaseMask |
+                 StructureNotifyMask);
+
+    /* create the main pixmap . . . */
+    DAMakePixmapFromData(master_xpm, &dockapp->pixmap, &dockapp->mask, 
+                        &dockapp->width, &dockapp->height);
+    DASetPixmap(dockapp->pixmap);
+    DASetShape(dockapp->mask);
 
     /* text area is 318x7, or 53 characters long */
     dockapp->text = XCreatePixmap(dockapp->display, dockapp->win, 318, 7,
@@ -207,23 +159,87 @@ static void new_window(char *name)
        pfatal("FATAL: Cannot create text scroll pixmap!\n");
        exit(1);
     }
+    DAShow();
+}
+
+static void copy_to_text_buffer(int sx, int sy, int w, int h, int dx, int dy)
+{
+    XCopyArea(dockapp->display, dockapp->pixmap, dockapp->text,
+             DAGC, sx, sy, w, h, dx, dy);
+}
+
+static void copy_to_text_area(int sx, int sy, int w, int h, int dx, int dy)
+{
+    XCopyArea(dockapp->display, dockapp->text, dockapp->pixmap,
+             DAGC, sx, sy, w, h, dx, dy);
+}
+
+static void scroll_text(void)
+{
+    static int start, end, stop;
+    int x = 6;                 /* x coord of the start of the text area */
+    int y = 50;                        /* y coord */
+    int width = 52;            /* width of the text area */
+    int height = 7;            /* height of the text area */
+    int tw = dockapp->tw;      /* width of the rendered text */
+    int sx, dx, w;
+
+    if (!dockapp->scroll) 
+       return;
+
+    /* 
+     * Conceptually this is viewing the text through a scrolling
+     * window - the window starts out with the end immediately before
+     * the text, and stops when the start of the window is immediately
+     * after the end of the text.
+     *
+     * We begin with the start of the window at pixel (0 - width) and
+     * as we scroll we render only the portion of the window above
+     * pixel 0. The destination of the copy during this period starts
+     * out at the end of the text area and works left as more of the
+     * text is being copied, until a full window is being copied.
+     *
+     * As the end of the window moves out past the end of the text, we
+     * want to keep the destination at the beginning of the text area, 
+     * but copy a smaller and smaller chunk of the text. Eventually the
+     * start of the window will scroll past the end of the text, at 
+     * which point we stop doing any work and wait to be reset.
+     */
+
+    if (dockapp->scroll_reset) {
+       start = 0 - width;
+       end = 0;
+       stop = 0;
+       clear_text_area();
+       dockapp->scroll_reset = 0;
+    }
+
+    if (stop)
+       return;
 
-    XShapeCombineMask(dockapp->display, dockapp->win, ShapeBounding, 0, 0,
-                     dockapp->mask, ShapeSet);
-    XShapeCombineMask(dockapp->display, dockapp->iconwin, ShapeBounding, 0,
-                     0, dockapp->mask, ShapeSet);
-
-    wmhints.initial_state = WithdrawnState;
-    wmhints.flags = StateHint;
-    wmhints.icon_window = dockapp->iconwin;
-    wmhints.icon_x = sizehints.x;
-    wmhints.icon_y = sizehints.y;
-    wmhints.window_group = dockapp->win;
-    wmhints.flags =
-       StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;
-    XSetWMHints(dockapp->display, dockapp->win, &wmhints);
-
-    XMapWindow(dockapp->display, dockapp->win);
+    w = 52;
+    if (end < 52)
+       w = end;
+    else if (end > tw)
+       w = 52 - (end - tw);
+       
+    dx = x + 52 - w;
+    if (end > tw)
+       dx = x;
+
+    sx = start;
+    if (start < 0)
+       sx = 0;
+
+    if (start > tw)
+       stop = 1;
+
+    clear_text_area();
+    copy_to_text_area(sx, 0, w, height, dx, y);
+    start += 2;
+    end += 2;
+
+    dockapp->update = 1;
 }
 
 static void render_text(char *string)
@@ -241,8 +257,7 @@ static void render_text(char *string)
 
     /* prepare the text area by clearing it */
     for (i = 0; i < 54; i++) {
-       XCopyArea(dockapp->display, dockapp->pixmap, dockapp->text,
-                 dockapp->gc, 133, 57, 6, 8, i * 6, 0);
+       copy_to_text_buffer(133, 57, 6, 8, i * 6, 0);
     }
     k = 0;
 
@@ -250,18 +265,14 @@ static void render_text(char *string)
        c = toupper(string[i]);
        if (c >= 'A' && c <= 'Z') {     /* letter */
            c = c - 'A';
-           XCopyArea(dockapp->display, dockapp->pixmap, dockapp->text,
-                     dockapp->gc, c * 6, 67, 6, 7, k, 0);
+           copy_to_text_buffer(c * 6, 67, 6, 7, k, 0);
        } else if (c >= '0' && c <= '9') {      /* number */
            c = c - '0';
-           XCopyArea(dockapp->display, dockapp->pixmap, dockapp->text,
-                     dockapp->gc, c * 6 + 66, 58, 6, 7, k, 0);
+           copy_to_text_buffer(c * 6 + 66, 58, 6, 7, k, 0);
        } else if (c == '.') {
-           XCopyArea(dockapp->display, dockapp->pixmap, dockapp->text,
-                     dockapp->gc, 140, 58, 6, 7, k, 0);
+           copy_to_text_buffer(140, 58, 6, 7, k, 0);
        } else if (c == '-') {
-           XCopyArea(dockapp->display, dockapp->pixmap, dockapp->text,
-                     dockapp->gc, 126, 58, 6, 7, k, 0);
+           copy_to_text_buffer(126, 58, 6, 7, k, 0);
        }
        k += 6;
     }
@@ -271,69 +282,14 @@ static void render_text(char *string)
     scroll_text();
 }
 
-static int open_display(char *display)
-{
-    dockapp->display = XOpenDisplay(display);
-    if (!dockapp->display) {
-       perr("Unable to open display '%s'\n", display);
-       return 1;
-    }
-    return 0;
-}
-
-static void scroll_text(void)
-{
-    static int pos, first, stop;
-    int x = 6;
-    int y = 50;
-    int width = 52;
-    int tw = dockapp->tw;
-
-    if (!dockapp->scroll) 
-       return;
-
-    if (dockapp->scroll_reset) {
-       pos = 0;
-       first = 0;
-       stop = 0;
-       XCopyArea(dockapp->display, dockapp->pixmap, dockapp->text,
-                 dockapp->gc, 0, 0, width, 7, x, y);
-       dockapp->scroll_reset = 0;
-    }
-
-    if (stop) {
-       return;
-    }
-
-    if ((first == 0) && pos == 0) {
-       pos = width;
-       first = 1;
-    }
-
-    if (pos == (0 - tw - 2)) {
-       first = 1;
-       pos = width;
-       stop = 1;
-       return;
-    }
-    pos -= 2;
-
-    if (pos > 0) {
-       copy_xpm_area(66, 9, pos, 7, x, y);     /* clear */
-       XCopyArea(dockapp->display, dockapp->text, dockapp->pixmap,
-                 dockapp->gc, 0, 0, width - pos, 7, x + pos, y);
-    } else {                   /* don't need to clear, already in text */
-       XCopyArea(dockapp->display, dockapp->text, dockapp->pixmap,
-                 dockapp->gc, abs(pos), 0, width, 7, x, y);
-    }
-    dockapp->update = 1;
-}
-
 static void display_percentage(int percent)
 {
     static int op = -1;
     static unsigned int obar;
     unsigned int bar;
+    int width = 54;            /* width of the bar */
+    float ratio = 100.0/width; /* ratio between the current percentage
+                                * and the number of pixels in the bar */
 
     if (percent == -1)
        percent = 0;
@@ -355,7 +311,7 @@ static void display_percentage(int percent)
        copy_xpm_area(95, 37, 21, 9, 37, 16);   /* 100% */
     op = percent;
 
-    bar = percent / 1.8518;
+    bar = (int)((float)percent / ratio);
 
     if (bar == obar)
        return;
@@ -454,7 +410,7 @@ static void blink_battery_glyph(void)
        really_blink_battery_glyph();
 }
 
-static void set_power_panel(void)
+static void set_power_panel(global_t *globals)
 {
     enum panel_states power = PS_NULL;
     battery_t *binfo = globals->binfo;
@@ -477,7 +433,7 @@ static void set_power_panel(void)
     if (binfo->charge_state == CHARGE)
        blink_power_glyph();
 
-    if (binfo->state == CRIT)
+    if ((binfo->state == CRIT) && (ap->power == BATT))
        blink_battery_glyph();
 
     if (binfo->state == HARD_CRIT) {
@@ -527,7 +483,7 @@ enum messages {
     M_NULL,    /* empty starting state */
 };
 
-static void set_message(void)
+static void set_message(global_t *globals)
 {
     static enum messages state = M_NULL;
     battery_t *binfo = globals->binfo;
@@ -583,7 +539,7 @@ static void set_message(void)
     }    
 }
 
-void set_time_display(void)
+void set_time_display(global_t *globals)
 {
     battery_t *binfo = &batteries[battery_no];
     
@@ -595,30 +551,16 @@ void set_time_display(void)
        invalid_time_display();
 }
 
-/*
- * This should really be fixed so that it can handle more than two batteries.
- */
-
-void set_id_1(void)
-{
-    copy_xpm_area(118, 38, 15, 15, 44, 30);
-}    
-
-void set_id_2(void)
-{
-    copy_xpm_area(136, 38, 15, 15, 44, 30);
-}
-
 void set_batt_id_area(int bno)
 {
-    switch(bno) {
-    case 0:
-       set_id_1();
-       break;
-    case 1:
-       set_id_2();
-       break;
-    }
+    int w = 7;                 /* Width of the number */
+    int h = 11;                        /* Height of the number */
+    int dx = 50;               /* x coord of the target area */
+    int dy = 31;               /* y coord of the target area */
+    int sx = (bno + 1) * 7;    /* source x coord */
+    int sy = 76;               /* source y coord */
+    
+    copy_xpm_area(sx, sy, w, h, dx, dy);
 }
 
 void usage(char *name)
@@ -632,6 +574,7 @@ void usage(char *name)
           "-m <battery number>\tbattery number to monitor\n"
           "-s <sample rate>\tnumber of times per minute to sample battery 
information\n"
           "\t\t\tdefault 20 (once every three seconds)\n"
+          "-f\t\t\tforce the use of capacity mode for calculating time 
remaining\n"
           "-n\t\t\tdo not blink\n"
           "-w\t\t\trun in command line mode\n"
           "-a <samples>\t\tsamples to average over (cli mode only)\n"
@@ -647,7 +590,7 @@ void print_version(void)
     printf(" Using libacpi version %s\n", LIBACPI_VER);
 }
 
-void cli_wmacpi(int samples)
+void cli_wmacpi(global_t *globals, int samples)
 {
     int i, j, sleep_time = 0;
     battery_t *binfo;
@@ -660,8 +603,8 @@ void cli_wmacpi(int samples)
     /* we want to acquire samples over some period of time, so . . . */
     for(i = 0; i < samples + 2; i++) {
        for(j = 0; j < globals->battery_count; j++)
-           acquire_batt_info(j);
-       acquire_global_info();
+           acquire_batt_info(globals, j);
+       acquire_global_info(globals);
        usleep(sleep_time);
     }
     
@@ -709,9 +652,11 @@ int main(int argc, char **argv)
     int sleep_rate = 10;
     int sleep_time = 1000000/sleep_rate;
     int scroll_count = 0;
+    enum rtime_mode rt_mode = RT_RATE;
     battery_t *binfo;
+    global_t *globals;
 
-    dockapp = calloc(1, sizeof(Dockapp));
+    dockapp = calloc(1, sizeof(struct dockapp));
     globals = calloc(1, sizeof(global_t));
 
     dockapp->blink = 1;
@@ -731,7 +676,7 @@ int main(int argc, char **argv)
      * are available /before/ we can decide if the battery we want to
      * monitor is available. */
     /* parse command-line options */
-    while ((ch = getopt(argc, argv, "d:c:m:s:a:hnwbrvV")) != EOF) {
+    while ((ch = getopt(argc, argv, "d:c:m:s:a:fhnwbrvV")) != EOF) {
        switch (ch) {
        case 'c':
            if (optarg) {
@@ -768,6 +713,9 @@ int main(int argc, char **argv)
                exit(1);
            }
            break;
+       case 'f':
+           rt_mode = RT_CAP;
+           break;
        case 'h':
            usage(argv[0]);
            return 0;
@@ -805,10 +753,12 @@ int main(int argc, char **argv)
        
     }
     
-    if (power_init())
+    if (power_init(globals))
        /* power_init functions handle printing error messages */
        exit(1);
 
+    globals->rt_mode = rt_mode;
+
     if (battery_no > globals->battery_count) {
        pfatal("Battery %d not available for monitoring.\n", battery_no);
        exit(1);
@@ -816,30 +766,26 @@ int main(int argc, char **argv)
 
     /* check for cli mode */
     if (cli) {
-       cli_wmacpi(samples);
+       cli_wmacpi(globals, samples);
        exit(0);
     }
 
     battery_no--;
 
-    /* open local or command-line specified display */
-    if (open_display(display))
-       exit(1);
-
     /* make new dockapp window */
     /* Don't even /think/ of asking me why, but if I set the window name to 
      * "acpi", the app refuses to dock properly - it's just plain /weird/.
      * So, wmacpi it is . . . */
-    new_window("wmacpi");
+    new_window(display, "wmacpi", argc, argv);
 
     /* get initial statistics */
-    acquire_all_info();
+    acquire_all_info(globals);
     binfo = &batteries[battery_no];
     globals->binfo = binfo;
     pinfo("monitoring battery %s\n", binfo->name);
     clear_time_display();
-    set_power_panel();
-    set_message();
+    set_power_panel(globals);
+    set_message(globals);
     set_batt_id_area(battery_no);
 
     /* main loop */
@@ -868,6 +814,7 @@ int main(int argc, char **argv)
                binfo = globals->binfo;
                pinfo("changing to monitor battery %d\n", battery_no + 1);
                set_batt_id_area(battery_no);
+               dockapp->update = 1;
                break;
            }
        }
@@ -899,19 +846,19 @@ int main(int argc, char **argv)
         * translates to 600 sleeps. So, we change the default sample
         * rate to 20, and the calculation below becomes . . .*/
        if (sample_count++ == ((sleep_rate*60)/samplerate)) {
-           acquire_all_info();
+           acquire_all_info(globals);
 
            /* we need to be able to reinitialise batteries and adapters, 
because
             * they change - you can hotplug batteries on most laptops these 
days
             * and who knows what kind of shit will be happening soon . . . */
            if (batt_count++ >= batt_reinit) {
-                   if(reinit_batteries()) 
+                   if(reinit_batteries(globals)) 
                            pfatal("Oh my god, the batteries are gone!\n");
                    batt_count = 0;
            }
 
            if (ac_count++ >= ac_reinit) {
-                   if(reinit_ac_adapters()) 
+                   if(reinit_ac_adapters(globals)) 
                            pfatal("What happened to our AC adapters?!?\n");
                    ac_count = 0;
            }
@@ -934,9 +881,9 @@ int main(int argc, char **argv)
         * much time remained until the batteries were fully charged . . . 
         * That would be rather useful, though given it would vary rather a lot
         * it seems likely that it'd be little more than a rough guesstimate. */
-       set_time_display();
-       set_power_panel();
-       set_message();
+       set_time_display(globals);
+       set_power_panel(globals);
+       set_message(globals);
        display_percentage(binfo->percentage);
        scroll_text();
 
-- 
1.9.1


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to