[Pkg-wmaker-commits] [wmacpi] 55/105: Imported Upstream version 2.2~rc3

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Aug 18 01:13:45 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmacpi.

commit eb74ba8056f3a95f1b026bf15237e176e5dc6ae8
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Mon Nov 24 05:55:15 2014 -0600

    Imported Upstream version 2.2~rc3
---
 ChangeLog  |  26 +++++
 acpi.c     |   2 +-
 libacpi.c  | 389 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 libacpi.h  |  17 +--
 master.xpm | 108 ++++++++---------
 wmacpi.c   | 135 ++++++++++++++-------
 6 files changed, 542 insertions(+), 135 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8524a1f..60e8b23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2008 March 18 2.2rc3
+	Some fixes for the sysfs interface support, supplied by
+	jblache at debian.org:
+
+	> Okay, I finally found time to make a new release including this
+	> patch - 2.2rc2. It's up on my website now.
+
+	I don't remember sending you the updated patch, as it turned out that
+	you can have different attributes in sysfs depending on what the
+	battery reports.
+
+	The current version is attached.
+
+	Thanks,
+
+	JB.
+
+	
+2008 March 14 2.2rc2
+	Support for the sysfs interface that became mandatory with kernel
+	2.6.24 (patch supplied by jblache at debian.org).
+
+	A number of graphics fixes also from jblache at debian.org.
+
+	Removed support for hardware reported critical battery status.
+	
 2007 July 14 2.2rc1
 	Major changes to command line handling and to the way we use
 	libdockapp, courtesy of Patrice Dumas. This should hopefully fix
diff --git a/acpi.c b/acpi.c
index ffca2cb..1518449 100644
--- a/acpi.c
+++ b/acpi.c
@@ -26,7 +26,7 @@
 
 #include "libacpi.h"
 
-#define ACPI_VER "2.2rc1"
+#define ACPI_VER "2.2rc3"
 
 global_t *globals;
 
diff --git a/libacpi.c b/libacpi.c
index 2a3890d..2d3a528 100644
--- a/libacpi.c
+++ b/libacpi.c
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <sys/types.h>
 #include <dirent.h>
 #include <time.h>
@@ -11,13 +12,129 @@
 #include "libacpi.h"
 
 extern char *state[];
-/* extern global_t *globals; */
+
+#define PROC_DATA_SOURCE    0
+#define SYSFS_DATA_SOURCE   1
+static int data_source;
 
 /* local proto */
 int acpi_get_design_cap(int batt);
 
+static int read_sysfs_file(char *node, char *prop, char *buf, size_t buflen)
+{
+    char tmp[256];
+    FILE *fp;
+    int ret;
+
+    ret = snprintf(tmp, sizeof(tmp), "/sys/class/power_supply/%s/%s", node, prop);
+    if (ret >= (int)sizeof(tmp)) {
+	perr("Path too long for %s/%s\n", node, prop);
+	return -1;
+    }
+
+    fp = fopen(tmp, "r");
+    if (fp == NULL) {
+	perr("Could not open %s/%s\n", node, prop);
+	return -2;
+    }
+
+    ret = fread(buf, 1, buflen - 1, fp);
+
+    fclose(fp);
+
+    if (ret == 0) {
+	perr("Could not read %s/%s\n", node, prop);
+	return -3;
+    }
+  
+    buf[ret] = '\0';
+
+    return 0;
+}
+
 /* initialise the batteries */
-int init_batteries(global_t *globals)
+static int sysfs_init_batteries(global_t *globals)
+{
+    DIR *battdir;
+    struct dirent *batt;
+    char *name;
+    char *names[MAXBATT];
+    char ps_type[16];
+    int i, j;
+    
+    /* now enumerate batteries */
+    globals->battery_count = 0;
+    battdir = opendir("/sys/class/power_supply");
+    if (battdir == NULL) {
+	pfatal("No batteries or ACPI not supported\n");
+	return 1;
+    }
+    while ((batt = readdir(battdir))) {
+	/* there's a serious problem with this code when there's
+	 * more than one battery: the readdir won't return the
+	 * entries in sorted order, so battery one won't 
+	 * necessarily be the first one returned. So, we need
+	 * to sort them ourselves before adding them to the 
+	 * batteries array. */
+	name = batt->d_name;
+	
+	/* skip ., .. and dotfiles */
+	if (name[0] == '.')
+	    continue;
+
+	if (read_sysfs_file(name, "type", ps_type, sizeof(ps_type)) < 0)
+	    continue;
+
+	if (strncmp("Battery", ps_type, 7) != 0)
+	    continue;
+
+	names[globals->battery_count] = strdup(name);
+	globals->battery_count++;
+    }
+    closedir(battdir);
+
+    /* A nice quick insertion sort, ala CLR. */
+    {
+	char *tmp1, *tmp2;
+	
+	for (i = 1; i < globals->battery_count; i++) {
+	    tmp1 = names[i];
+	    j = i - 1;
+	    while ((j >= 0) && ((strcmp(tmp1, names[j])) < 0)) {
+		tmp2 = names[j+1];
+		names[j+1] = names[j];
+		names[j] = tmp2;
+	    }
+	}
+    }
+    
+    for (i = 0; i < globals->battery_count; i++) {
+	snprintf(batteries[i].name, MAX_NAME, "%s", names[i]);
+	pdebug("battery detected at /sys/class/power_supply/%s\n", batteries[i].name);
+	pinfo("found battery %s\n", names[i]);
+
+	if (read_sysfs_file(batteries[i].name, "energy_now", ps_type, sizeof(ps_type)) == 0)
+	    batteries[i].sysfs_capa_mode = SYSFS_CAPA_ENERGY;
+	else if (read_sysfs_file(batteries[i].name, "charge_now", ps_type, sizeof(ps_type)) == 0)
+	    batteries[i].sysfs_capa_mode = SYSFS_CAPA_CHARGE;
+	else if (read_sysfs_file(batteries[i].name, "capacity", ps_type, sizeof(ps_type)) == 0) {
+	    batteries[i].sysfs_capa_mode = SYSFS_CAPA_PERCENT;
+	    batteries[i].design_cap = 100;
+	    batteries[i].last_full_cap = 100;
+	} else
+	    batteries[i].sysfs_capa_mode = SYSFS_CAPA_ERR;
+    }
+
+    /* tell user some info */
+    pdebug("%d batteries detected\n", globals->battery_count);
+    pinfo("libacpi: found %d batter%s\n", globals->battery_count,
+	  (globals->battery_count == 1) ? "y" : "ies");
+
+    return 0;
+}
+
+/* initialise the batteries */
+static int procfs_init_batteries(global_t *globals)
 {
     DIR *battdir;
     struct dirent *batt;
@@ -83,6 +200,14 @@ int init_batteries(global_t *globals)
     return 0;
 }
 
+int init_batteries(global_t *globals)
+{
+  if (data_source == SYSFS_DATA_SOURCE)
+    return sysfs_init_batteries(globals);
+  else
+    return procfs_init_batteries(globals);
+}
+
 /* a stub that just calls the current function */
 int reinit_batteries(global_t *globals)
 {
@@ -90,10 +215,62 @@ int reinit_batteries(global_t *globals)
     return init_batteries(globals);
 }
 
+/* the actual name of the subdirectory under power_supply may
+ * be anything, so we need to read the directory and use the
+ * name we find there. */
+static int sysfs_init_ac_adapters(global_t *globals)
+{
+    DIR *acdir;
+    struct dirent *adapter;
+    adapter_t *ap = &globals->adapter;
+    char *name;
+    char ps_type[16];
+
+    acdir = opendir("/sys/class/power_supply");
+    if (acdir == NULL) {
+	pfatal("Unable to open /sys/class/power_supply -"
+		" are you sure this system supports ACPI?\n");
+	return 1;
+    }
+    name = NULL;
+    while ((adapter = readdir(acdir)) != NULL) {
+	name = adapter->d_name;
+
+	if (name[0] == '.') {
+	  name = NULL;
+	  continue;
+	}
+
+	if (read_sysfs_file(name, "type", ps_type, sizeof(ps_type)) < 0) {
+	  name = NULL;
+	  continue;
+	}
+
+	if (strncmp("Mains", ps_type, 5) == 0) {
+	  pdebug("found adapter %s\n", name);
+	  break;
+	} else {
+	  name = NULL;
+	}
+    }
+    closedir(acdir);
+
+    if (name == NULL) {
+      perr("No AC adapter found !\n");
+      return 1;
+    }
+
+    /* we'll just use the first adapter we find ... */
+    ap->name = strdup(name);
+    pinfo("libacpi: found ac adapter %s\n", ap->name);
+    
+    return 0;
+}
+
 /* 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(global_t *globals)
+static int procfs_init_ac_adapters(global_t *globals)
 {
     DIR *acdir;
     struct dirent *adapter;
@@ -125,6 +302,14 @@ int init_ac_adapters(global_t *globals)
     return 0;
 }
 
+int init_ac_adapters(global_t *globals)
+{
+  if (data_source == SYSFS_DATA_SOURCE)
+    return sysfs_init_ac_adapters(globals);
+  else
+    return procfs_init_ac_adapters(globals);
+}
+
 /* stub that does nothing but call the normal init function */
 int reinit_ac_adapters(global_t *globals)
 {
@@ -162,6 +347,15 @@ int power_init(global_t *globals)
     /* yep, all good */
     fclose(acpi);
 
+    /* determine data source */
+    if (access("/sys/class/power_supply", R_OK | X_OK) == 0) {
+	data_source = SYSFS_DATA_SOURCE;
+	pinfo("Selecting sysfs as the data source\n");
+    } else {
+	data_source = PROC_DATA_SOURCE;
+	pinfo("Selecting procfs as the data source\n");
+    }
+
     if (!(retval = init_batteries(globals)))
 	retval = init_ac_adapters(globals);
 
@@ -187,7 +381,7 @@ int power_reinit(global_t *globals)
     return retval;
 }
 
-char *get_value(char *string)
+static char *get_value(char *string)
 {
     char *retval;
     int i;
@@ -203,14 +397,28 @@ char *get_value(char *string)
     return retval;
 }
 
-int check_error(char *buf)
+static int check_error(char *buf)
 {
     if(strstr(buf, "ERROR") != NULL)
 	return 1;
     return 0;
 }
 
-power_state_t get_power_status(global_t *globals)
+static power_state_t sysfs_get_power_status(global_t *globals)
+{
+    char online[2];
+    adapter_t *ap = &globals->adapter;
+
+    if (read_sysfs_file(ap->name, "online", online, sizeof(online)) < 0)
+      return PS_ERR;
+
+    if (*online == '1')
+	return AC;
+    else
+	return BATT;
+}
+
+static power_state_t procfs_get_power_status(global_t *globals)
 {
     FILE *file;
     char buf[1024];
@@ -232,7 +440,140 @@ power_state_t get_power_status(global_t *globals)
 	return BATT;
 }
 
-int get_battery_info(int batt_no)
+power_state_t get_power_status(global_t *globals)
+{
+    if (data_source == SYSFS_DATA_SOURCE)
+	return sysfs_get_power_status(globals);
+    else
+	return procfs_get_power_status(globals);
+}
+
+static int sysfs_get_battery_info(global_t *globals, int batt_no)
+{
+    battery_t *info = &batteries[batt_no];
+    char buf[32];
+    int ret;
+
+    /* check to see if battery is present */
+    ret = read_sysfs_file(info->name, "present", buf, sizeof(buf));
+    if (ret < 0) {
+	/* interestingly, when the battery is not present, the whole
+	 * /sys/class/power_supply/BATn directory does not exist.
+	 * Yes, this is broken.
+	 */
+	if (ret == -2)
+	    info->present = 0;
+
+	/* reinit batteries, this one went away and it's very
+	   possible there just isn't any other one */
+	reinit_batteries(globals);
+
+	return 0;
+    }
+
+    info->present = (*buf == '1');
+    if (!info->present) {
+	pinfo("Battery %s not present\n", info->name);
+	return 0;
+    }
+
+    /* get design capacity
+     * note that all these integer values can also contain the
+     * string 'unknown', so we need to check for this. */
+    if (info->sysfs_capa_mode == SYSFS_CAPA_ENERGY) {
+	if (read_sysfs_file(info->name, "energy_full_design", buf, sizeof(buf)) < 0)
+	    info->design_cap = -1;
+	else
+	    info->design_cap = strtoul(buf, NULL, 10) / 1000;
+
+	/* get last full capacity */
+	if (read_sysfs_file(info->name, "energy_full", buf, sizeof(buf)) < 0)
+	    info->last_full_cap = -1;
+	else
+	    info->last_full_cap = strtoul(buf, NULL, 10) / 1000;
+    } else if (info->sysfs_capa_mode == SYSFS_CAPA_CHARGE) {
+	/* get design capacity */
+	if (read_sysfs_file(info->name, "charge_full_design", buf, sizeof(buf)) < 0)
+	    info->design_cap = -1;
+	else
+	    info->design_cap = strtoul(buf, NULL, 10) / 1000;
+
+	/* get last full capacity */
+	if (read_sysfs_file(info->name, "charge_full", buf, sizeof(buf)) < 0)
+	    info->last_full_cap = -1;
+	else
+	    info->last_full_cap = strtoul(buf, NULL, 10) / 1000;
+    } else if (info->sysfs_capa_mode != SYSFS_CAPA_PERCENT) {
+	info->design_cap = -1;
+	info->last_full_cap = -1;
+    }
+
+
+    /* get design voltage */
+    if (read_sysfs_file(info->name, "voltage_min_design", buf, sizeof(buf)) < 0)
+	info->design_voltage = -1;
+    else
+	info->design_voltage = strtoul(buf, NULL, 10) / 1000;
+
+    /* get charging state */
+    if (read_sysfs_file(info->name, "status", buf, sizeof(buf)) < 0) {
+	info->charge_state = CH_ERR;
+    } else {
+	if (strncmp(buf, "Unknown", 7) == 0)
+	    info->charge_state = CH_ERR;
+	else if (strncmp(buf, "Discharging", 11) == 0)
+	    info->charge_state = DISCHARGE;
+	else if (strncmp(buf, "Charging", 8) == 0)
+	    info->charge_state = CHARGE;
+	else if (strncmp(buf, "Not charging", 12) == 0)
+	    info->charge_state = NO_CHARGE;
+	else if (strncmp(buf, "Full", 4) == 0)
+	    info->charge_state = FULL; /* DISCHARGE ? as per old comment ... */
+    }
+
+    /* get current rate of burn 
+     * note that if it's on AC, this will report 0 */
+    if (read_sysfs_file(info->name, "current_now", buf, sizeof(buf)) < 0)
+	info->present_rate = -1;
+    else {
+	int rate;
+	rate = strtoul(buf, NULL, 10) / 1000;
+	info->present_rate = (rate != 0) ? rate : info->present_rate;
+    }
+
+    if (info->sysfs_capa_mode == SYSFS_CAPA_ENERGY) {
+	/* get remaining capacity */
+	if (read_sysfs_file(info->name, "energy_now", buf, sizeof(buf)) < 0)
+	    info->remaining_cap = -1;
+	else
+	    info->remaining_cap = strtoul(buf, NULL, 10) / 1000;
+
+    } else if (info->sysfs_capa_mode == SYSFS_CAPA_CHARGE) {
+	/* get remaining capacity */
+	if (read_sysfs_file(info->name, "charge_now", buf, sizeof(buf)) < 0)
+	    info->remaining_cap = -1;
+	else
+	    info->remaining_cap = strtoul(buf, NULL, 10) / 1000;
+    } else if (info->sysfs_capa_mode == SYSFS_CAPA_PERCENT) {
+	/* get remaining capacity */
+	if (read_sysfs_file(info->name, "capacity", buf, sizeof(buf)) < 0)
+	    info->remaining_cap = -1;
+	else
+	    info->remaining_cap = strtoul(buf, NULL, 10) / 1000;
+    } else {
+	info->remaining_cap = -1;
+    }
+
+    /* get current voltage */
+    if (read_sysfs_file(info->name, "voltage_now", buf, sizeof(buf)) < 0)
+	info->present_voltage = -1;
+    else
+	info->present_voltage = strtoul(buf, NULL, 10) / 1000;
+
+    return 1;
+}
+
+static int procfs_get_battery_info(global_t *globals, int batt_no)
 {
     FILE *file;
     battery_t *info = &batteries[batt_no];
@@ -241,6 +582,8 @@ int get_battery_info(int batt_no)
     int buflen;
     char *val;
 
+    globals = globals; /* silencing a warning */
+
     if ((file = fopen(info->info_file, "r")) == NULL) {
 	/* this is cheating, but string concatenation should work . . . */
 	pfatal("Could not open %s:", info->info_file );
@@ -325,18 +668,6 @@ int get_battery_info(int batt_no)
 	return 0;
     }
 
-    /* get capacity state 
-     * note that this has only two values (at least, in the 2.4.21-rc2
-     * source code) - ok and critical. */
-    entry = strstr(buf, "capacity state:");
-    val = get_value(entry);
-    if (val[0] == 'u')
-	info->capacity_state = CS_ERR;
-    else if ((strncmp(val, "ok", 2)) == 0)
-	info->capacity_state = OK;
-    else
-	info->capacity_state = CRITICAL;
-
     /* get charging state */
     entry = strstr(buf, "charging state:");
     val = get_value(entry);
@@ -385,6 +716,14 @@ int get_battery_info(int batt_no)
     return 1;
 }
 
+int get_battery_info(global_t *globals, int batt_no)
+{
+  if (data_source == SYSFS_DATA_SOURCE)
+      return sysfs_get_battery_info(globals, batt_no);
+  else
+      return procfs_get_battery_info(globals, batt_no);
+}
+
 /*
  * 2003-7-1.
  * In order to make this code more convenient for things other than
@@ -562,7 +901,7 @@ void acquire_batt_info(global_t *globals, int batt)
     battery_t *binfo;
     adapter_t *ap = &globals->adapter;
     
-    get_battery_info(batt);
+    get_battery_info(globals, batt);
     
     binfo = &batteries[batt];
     
@@ -594,16 +933,6 @@ void acquire_batt_info(global_t *globals, int batt)
      * globals->power value . . . .*/
     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 
-	 * check if we're at a critical battery level, and calculate
-	 * other interesting stuff . . . */
-	if (binfo->capacity_state == CRITICAL) {
-	    pinfo("Received critical battery status");
-	    ap->power = HARD_CRIT;
-	}
-    }
-    
     binfo->charge_time = calc_charge_time(globals, batt);
 
     /* and finally, we tell anyone who wants to use this information
diff --git a/libacpi.h b/libacpi.h
index fd89c2f..07e5b9a 100644
--- a/libacpi.h
+++ b/libacpi.h
@@ -2,7 +2,7 @@
 #define _LIBACPI_H_
 
 
-#define LIBACPI_VER "0.93"
+#define LIBACPI_VER "0.95"
 
 /* Here because we need it for definitions in this file . . . */
 #define MAX_NAME 128
@@ -26,21 +26,23 @@ typedef enum {
     MED,
     LOW,
     CRIT,
-    HARD_CRIT,
     BS_ERR,
 } batt_state_t;
 
 typedef enum {
     CHARGE,
     DISCHARGE,
+    FULL,
+    NO_CHARGE,
     CH_ERR,
 } charge_state_t;
 
 typedef enum {
-    OK,
-    CRITICAL,
-    CS_ERR,
-} cap_state_t;
+    SYSFS_CAPA_ENERGY,
+    SYSFS_CAPA_CHARGE,
+    SYSFS_CAPA_PERCENT,
+    SYSFS_CAPA_ERR,
+} sysfs_capa_t;
 
 typedef struct {
     /* general info */
@@ -48,12 +50,13 @@ typedef struct {
     /* these two are conveniences */
     char info_file[MAX_NAME];
     char state_file[MAX_NAME];
+    /* sysfs capacity mode */
+    sysfs_capa_t sysfs_capa_mode;
     int present; 
     int design_cap;		/* assuming mAh */
     int last_full_cap;
     int design_voltage;		/* in mV */
     /* state info */
-    cap_state_t capacity_state;
     charge_state_t charge_state;
     int present_rate;		/* in mAh */
     int remaining_cap;		/* in mAh */
diff --git a/master.xpm b/master.xpm
index e958772..53b52dc 100644
--- a/master.xpm
+++ b/master.xpm
@@ -96,9 +96,9 @@ static char * master_xpm[] = {
 " .	c #004941",
 "..	c #20B2AE",
 "+.	c #303030",
-"@.	c #027E72",
-"#.	c #188A86",
-"$.	c #22B2AE",
+"@.	c #188A86",
+"#.	c #22B2AE",
+"$.	c #027E72",
 "%.	c #034A40",
 "&.	c #107D79",
 "                                                                                                                                .   + @ # $ % & * = - % ; > , ' % ) ! ~ { % ] ^ / ( % _ : < [ % } | 1 2 % 3 4 5 6 % 7 8 9 0 % a b c d % e f g h                                                                           ",
@@ -119,39 +119,39 @@ 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   % @......... at .% @......... at .% % % % % @......... at .% @......... at .%       ",
-"        . % % % % % ..% % % % ..% % % % ..% % % % % % % % ....% `     . % %  .%  .% % %  .%  .% % %  .% % ..% ..% % % `         .   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   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       ",
+"        . % % % % % ..% % % % ......% % ..% % % % % % % % ..% % `     . % %  .%  .% % %  .%  .% % %  .% ..% ..% ..% % `         .   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   %  .% % % %  .%  .% % % %  .% % ..% %  .% % % %  .%  .% % % %  .%       ",
+"        . % ..% % % % % % % % % % % % % ....................% % `     . % % % % %  . . .% % %  . . .% % % % % ..% % % `         .   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   % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %       ",
 "        ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `     ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `         .                                                                                                                                                                                         ",
 "                                                                                                                                .   % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %                                           ",
-"                                                                                                                                .   % % ......% % %  . . .#.% #.......#.% #.......#.% #. . . .#.% #.......#.% #.......#.% #.......#.% #.......#.% #.......#.% % ..% % % % % % %                                           ",
+"                                                                                                                                .   % % ......% % %  . . . at .% @....... at .% @....... at .% @. . . . at .% @....... at .% @....... at .% @....... at .% @....... at .% @....... at .% % ..% % % % % % %                                           ",
 "        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .     . . . . . . . . . . . . . . . . `         .   % ..% % % ..%  .% % % ..%  .% % % ..%  .% % % ..% ..% % % ..% ..% % %  .% ..% % %  .%  .% % % ..% ..% % % ..% ..% % % ..% ..% ..% ..% % ..%                                           ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `     % % % % % % % % % % % % % % % % `         .   % ..% % % ..%  .% % % ..%  .% % % ..%  .% % % ..% ..% % % ..% ..% % %  .% ..% % %  .%  .% % % ..% ..% % % ..% ..% % % ..% % ..% ..% % % #.%                                           ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `     % % % % % % % % % % % % % % % % `         .   % #. . . .#.% %  . . .#.% #.......#.% % ......#.% #.......#.% #.......#.% #.......#.% %  . . .#.% #.......#.% #.......#.% % % ..% % % % % %                                           ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `     % % % % % % % % % % % % % % % % `         .   % ..% % % ..%  .% % % ..%  .% % % ..%  .% % % ..% ..% % % ..% ..% % %  .% ..% % %  .%  .% % % ..% ..% % % ..% ..% % % ..% % ..% ..% % % @.%                                           ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `     % % % % % % % % % % % % % % % % `         .   % @. . . . at .% %  . . . at .% @....... at .% % ...... at .% @....... at .% @....... at .% @....... at .% %  . . . at .% @....... at .% @....... at .% % % ..% % % % % %                                           ",
 "        . % % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% % % `     % % % % % % % % %  . . . .% % % `         .   % ..% % % ..%  .% % % ..% ..% % %  .%  .% % % ..%  .% % % ..%  .% % % ..% ..% % % ..%  .% % % ..% ..% % % ..%  .% % % ..% % ..% ..% % % % %                                           ",
 "        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% % `     % % % % % % % %  .% % % %  .% % `         .   % ..% % % ..%  .% % % ..% ..% % %  .%  .% % % ..%  .% % % ..%  .% % % ..% ..% % % ..%  .% % % ..% ..% % % ..%  .% % % ..% ..% ..% ..% % ..%                                           ",
-"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% % `     % $.$.$.$.% % %  .% % % %  .% % `         .   % % ......% % %  . . .#.% #.......#.% #.......#.% %  . . .#.% #.......#.% #.......#.% %  . . .#.% #.......#.% #.......#.% % % % ..% % % #.%                                           ",
-"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% % `     % $.% % % $.% %  .% % % %  .% % `         .   % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %                                           ",
-"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% % `     % $.% % % $.% %  .% % % %  .% % `         .                                                                                                                                                                                         ",
-"        . % % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% % % `     % $.% % % $.% % %  . . . .% % % `         .   % % % % % % % % % % % % % %   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   . . . . . . . . . . . . . . . . `                                               ",
-"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% % `     % $.$.$.$.% % %  .% % % %  .% % `         .   % % % % % % ..........% % %   % ....................% %   % #.% % ......% % % ......% % % ..% % % %   % % % % % % % % % % % % % % % % `                                               ",
-"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% % `     % $.% % % $.% %  .% % % %  .% % `         .   % % % % % ..% % % % ......%   % ..% % % % % % % % ..% %   % ..% ..% % % ..% ..% % % ..% ..% ..% ..%   % % % % % % % % % % % % % % % % `                                               ",
-"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% % `     % $.% % % $.% %  .% % % %  .% % `         .   % % % % % ..% % % % ..% % %   % ..% % % % % % % % ....%   % ..% ..% % % ..% ..% % % ..% % ..% ..% %   % % % % % % % % %  . . . .% % % `                                               ",
-"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% % `     % $.% % % $.% %  .% % % %  .% % `         .   % % % ......% % % % ..% % %   % ..% % % % % % % % ....%   % #.% #. . . .#.% #. . . .#.% % % ..% % %   % % % % % % % %  .% % % %  .% % `                                               ",
-"        . % % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% % % `     % $.$.$.$.% % % %  . . . .% % % `         .   % % ..% % ..% % % % ......%   % ..% % % % % % % % ....%   % ..% ..% % % ..% ..% % % ..% % ..% ..% %   % $.$.$.$.% % %  .% % % %  .% % `                                               ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `     % % % % % % % % % % % % % % % % `         .   % ..% % % % ..........% % %   % ..% % % % % % % % ..% %   % ..% ..% % % ..% ..% % % ..% ..% ..% ..%   % $.% % % $.% %  .% % % %  .% % `                                               ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `     % % % % % % % % % % % % % % % % `         .   % ..% % % % % % % % % % % %   % ....................% %   % #.% % ......% % % ......% % % % % ..% %   % $.% % % $.% %  .% % % %  .% % `                                               ",
-"        ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `     ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `         .   % % % % % % % % % % % % % %   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   % $.% % % $.% % %  . . . .% % % `                                               ",
-"                                                                                                                                .                                                                                                         % $.$.$.$.% % %  .% % % %  .% % `                                               ",
-"                                                                                                                                .   % % % % % % % % % % % % % %   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   % $.% % % $.% %  .% % % %  .% % `                                               ",
-"        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .         .   % % % % % %  . . . . .% % %   %  . . . . . . . . . .% %   % % % %  . . .% % %  . . .% % %  .% % % %   % $.% % % $.% %  .% % % %  .% % `                                               ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % % % % %  .% % % %  . . .%   %  .% % % % % % % %  .% %   %  .%  .% % %  .%  .% % %  .%  .%  .%  .%   % $.% % % $.% %  .% % % %  .% % `                                               ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % % % % %  .% % % %  .% % %   %  .% % % % % % % %  . .%   %  .%  .% % %  .%  .% % %  .% %  .%  .% %   % $.$.$.$.% % % %  . . . .% % % `                                               ",
+"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% % `     % #.#.#.#.% % %  .% % % %  .% % `         .   % % ......% % %  . . . at .% @....... at .% @....... at .% %  . . . at .% @....... at .% @....... at .% %  . . . at .% @....... at .% @....... at .% % % % ..% % % @.%                                           ",
+"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% % `     % #.% % % #.% %  .% % % %  .% % `         .   % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %                                           ",
+"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% % `     % #.% % % #.% %  .% % % %  .% % `         .                                                                                                                                                                                         ",
+"        . % % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% % % `     % #.% % % #.% % %  . . . .% % % `         .   % % % % % % % % % % % % % %   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   . . . . . . . . . . . . . . . . `                                               ",
+"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% % `     % #.#.#.#.% % %  .% % % %  .% % `         .   % % % % % % ..........% % %   % ....................% %   % @.% % ......% % % ......% % % ..% % % %   % % % % % % % % % % % % % % % % `                                               ",
+"        . % %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .% % `     % #.% % % #.% %  .% % % %  .% % `         .   % % % % % ..% % % % ......%   % ..% % % % % % % % ..% %   % ..% ..% % % ..% ..% % % ..% ..% ..% ..%   % % % % % % % % % % % % % % % % `                                               ",
+"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% % `     % #.% % % #.% %  .% % % %  .% % `         .   % % % % % ..% % % % ..% % %   % ..% % % % % % % % ....%   % ..% ..% % % ..% ..% % % ..% % ..% ..% %   % % % % % % % % %  . . . .% % % `                                               ",
+"        . % %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .% % `     % #.% % % #.% %  .% % % %  .% % `         .   % % % ......% % % % ..% % %   % ..% % % % % % % % ....%   % @.% @. . . . at .% @. . . . at .% % % ..% % %   % % % % % % % %  .% % % %  .% % `                                               ",
+"        . % % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% % % `     % #.#.#.#.% % % %  . . . .% % % `         .   % % ..% % ..% % % % ......%   % ..% % % % % % % % ....%   % ..% ..% % % ..% ..% % % ..% % ..% ..% %   % #.#.#.#.% % %  .% % % %  .% % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `     % % % % % % % % % % % % % % % % `         .   % ..% % % % ..........% % %   % ..% % % % % % % % ..% %   % ..% ..% % % ..% ..% % % ..% ..% ..% ..%   % #.% % % #.% %  .% % % %  .% % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `     % % % % % % % % % % % % % % % % `         .   % ..% % % % % % % % % % % %   % ....................% %   % @.% % ......% % % ......% % % % % ..% %   % #.% % % #.% %  .% % % %  .% % `                                               ",
+"        ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `     ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `         .   % % % % % % % % % % % % % %   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   % #.% % % #.% % %  . . . .% % % `                                               ",
+"                                                                                                                                .                                                                                                         % #.#.#.#.% % %  .% % % %  .% % `                                               ",
+"                                                                                                                                .   % % % % % % % % % % % % % %   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %   % #.% % % #.% %  .% % % %  .% % `                                               ",
+"        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .         .   % % % % % %  . . . . .% % %   %  . . . . . . . . . .% %   % % % %  . . .% % %  . . .% % %  .% % % %   % #.% % % #.% %  .% % % %  .% % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % % % % %  .% % % %  . . .%   %  .% % % % % % % %  .% %   %  .%  .% % %  .%  .% % %  .%  .%  .%  .%   % #.% % % #.% %  .% % % %  .% % `                                               ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % % % % %  .% % % %  .% % %   %  .% % % % % % % %  . .%   %  .%  .% % %  .%  .% % %  .% %  .%  .% %   % #.#.#.#.% % % %  . . . .% % % `                                               ",
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % % %  . . .% % % %  .% % %   %  .% % % % % % % %  . .%   % % % %  . . .% % %  . . .% % % %  .% % %   % % % % % % % % % % % % % % % % `                                               ",
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % %  .% %  .% % % %  . . .%   %  .% % % % % % % %  . .%   %  .%  .% % %  .%  .% % %  .% %  .%  .% %   % % % % % % % % % % % % % % % % `                                               ",
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   %  .% % % %  . . . . .% % %   %  .% % % % % % % %  .% %   %  .%  .% % %  .%  .% % %  .%  .%  .%  .%   ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `                                               ",
@@ -159,33 +159,33 @@ static char * master_xpm[] = {
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % % % % % % % % % % % % % %   % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % %                                                                                   ",
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .                                                                                                                                                                                         ",
 "        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %   % % % % % %                       ",
-"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % % $.$.$.% % % % % % @.% @.$.$.$. at .% @.$.$.$. at .% @.% % % @.% @.$.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% % % % % % % % % % % % %   % % % % % %                       ",
-"        ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `         .   % $.% % % $.% % % % % $.% % % % % $.% % % % % $.% $.% % % $.% $.% % % % % $.% % % % % % % % % $.% $.% % % $.% $.% % % $.% % % % % % % % % % % % %   % % % % % %                       ",
-"                                                                                                                                .   % $.% % % $.% % % % % $.% % % % % $.% % % % % $.% $.% % % $.% $.% % % % % $.% % % % % % % % % $.% $.% % % $.% $.% % % $.% % % % % % % % % % % % %   % % % % % %                       ",
-"                                                                                                                                .   % @.% % % @.% % % % % @.% @.$.$.$. at .% % $.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% % % % % @.% %.$.$.$.%.% @.$.$.$. at .% @.$.$.$. at .% % % % % % %   % % % % % %                       ",
-"                                                                                                                                .   % $.% % % $.% % % % % $.% $.% % % % % % % % % $.% % % % % $.% % % % % $.% $.% % % $.% % % % % $.% $.% % % $.% % % % % $.% % % % % % % % % % % % %   % % % % % %                       ",
-"                                                                                                                                .   % $.% % % $.% % % % % $.% $.% % % % % % % % % $.% % % % % $.% % % % % $.% $.% % % $.% % % % % $.% $.% % % $.% % % % % $.% % % % % % % % % % % % %   % % % % % %                       ",
-". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   % % $.$.$.% % % % % % $.% @.$.$.$. at .% @.$.$.$. at .% % % % % @.% @.$.$.$. at .% @.$.$.$. at .% % % % % @.% @.$.$.$. at .% @.$.$.$. at .% % % % % % % % % % % % %   % % % % $.%                       ",
+"        . % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % `         .   % % #.#.#.% % % % % % $.% $.#.#.#.$.% $.#.#.#.$.% $.% % % $.% $.#.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% % % % % % % % % % % % %   % % % % % %                       ",
+"        ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `         .   % #.% % % #.% % % % % #.% % % % % #.% % % % % #.% #.% % % #.% #.% % % % % #.% % % % % % % % % #.% #.% % % #.% #.% % % #.% % % % % % % % % % % % %   % % % % % %                       ",
+"                                                                                                                                .   % #.% % % #.% % % % % #.% % % % % #.% % % % % #.% #.% % % #.% #.% % % % % #.% % % % % % % % % #.% #.% % % #.% #.% % % #.% % % % % % % % % % % % %   % % % % % %                       ",
+"                                                                                                                                .   % $.% % % $.% % % % % $.% $.#.#.#.$.% % #.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% % % % % $.% %.#.#.#.%.% $.#.#.#.$.% $.#.#.#.$.% % % % % % %   % % % % % %                       ",
+"                                                                                                                                .   % #.% % % #.% % % % % #.% #.% % % % % % % % % #.% % % % % #.% % % % % #.% #.% % % #.% % % % % #.% #.% % % #.% % % % % #.% % % % % % % % % % % % %   % % % % % %                       ",
+"                                                                                                                                .   % #.% % % #.% % % % % #.% #.% % % % % % % % % #.% % % % % #.% % % % % #.% #.% % % #.% % % % % #.% #.% % % #.% % % % % #.% % % % % % % % % % % % %   % % % % % %                       ",
+". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   % % #.#.#.% % % % % % #.% $.#.#.#.$.% $.#.#.#.$.% % % % % $.% $.#.#.#.$.% $.#.#.#.$.% % % % % $.% $.#.#.#.$.% $.#.#.#.$.% % % % % % % % % % % % %   % % % % #.%                       ",
 "                                                                                                                                    % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %                                     ",
 "% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % ",
-"% %.$.$.$.%.% @.$.$.$.% % @.$.$.$. at .% @.$.$.$.% % @.$.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% @.% % % @.% % % @.% % % % % % % @.% @.% % % @.% @.% % % % % $.% % % $.% @.$.$.$.% % @.$.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% @.$.$.$. at .% @.% % % @.% @.% % % @.% @.% % % @.% @.% % % @.% @.% % % @.% @.$.$.$. at .% ",
-"% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% % % % % $.% % % $.% % % $.% % % % % % % $.% $.% % % $.% $.% % % % % $.$.% $.$.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % % % % % $.% % % $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% % % % % $.% ",
-"% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% % % % % $.% % % $.% % % $.% % % % % % % $.% $.% % $.%.% $.% % % % % $.% $.% $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % % % % % $.% % % $.% % % $.% $.% % % $.% $.% % % $.% %.$.% $.%.% $.% % % $.% % % % $.%.% ",
-"% @.$.$.$. at .% @.$.$.$.% % @.% % % % % @.% % % @.% @.$.$.$.% % @.$.$.$.% % @.%.$.$. at .% @.$.$.$. at .% % % @.% % % % % % % @.% @.$.$.%.% % @.% % % % % @.% % % @.% @.% % % @.% @.% % % @.% @.$.$.$. at .% @.$.% % @.% @.$.$.$.% % @.$.$.$. at .% % % @.% % % @.% % % @.% @.% % % @.% @.% % % @.% % %.$.%.% % @.$.$.$. at .% % %.$.%.% % ",
-"% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% % % $.% $.% % % $.% % % $.% % % % % % % $.% $.% % $.%.% $.% % % % % $.% % % $.% $.% % % $.% $.% % % $.% $.% % % % % $.% $.% $.% $.% % % $.% % % % % $.% % % $.% % % $.% % % $.% $.% % % $.% $.% $.% $.% %.$.% $.%.% % % % % $.% %.$.% % % % ",
-"% $.% % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % % % $.% % % % % $.% % % $.% $.% % % $.% % % $.% % % % % % % $.% $.% % % $.% $.% % % % % $.% % % $.% $.% % % $.% $.% % % $.% $.% % % % % $.% % $.$.% $.% % % $.% % % % % $.% % % $.% % % $.% % % $.% $.% % % $.% $.$.% $.$.% $.% % % $.% % % % % $.% $.% % % % % ",
-"% @.% % % @.% @.$.$.$.% % @.$.$.$. at .% $.$.$.$.% % @.$.$.$. at .% $.% % % % % @.$.$.$. at .% @.% % % @.% % % $.% % % @.$.$.$. at .% @.% % % @.% @.$.$.$.%.% @.% % % @.% $.% % % $.% @.$.$.$. at .% @.% % % % % @.$.$.$. at .% @.% % % @.% @.$.$.$. at .% % % @.% % % %.$.$.$.$.% % $.$.$.% % $.% % % $.% @.% % % $.% @.$.$.$. at .% @.$.$.$. at .% ",
+"% %.#.#.#.%.% $.#.#.#.% % $.#.#.#.$.% $.#.#.#.% % $.#.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% $.% % % $.% % % $.% % % % % % % $.% $.% % % $.% $.% % % % % #.% % % #.% $.#.#.#.% % $.#.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% $.#.#.#.$.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.% % % $.% $.#.#.#.$.% ",
+"% #.% % % #.% #.% % % #.% #.% % % % % #.% % % #.% #.% % % % % #.% % % % % #.% % % % % #.% % % #.% % % #.% % % % % % % #.% #.% % % #.% #.% % % % % #.#.% #.#.% #.% % % #.% #.% % % #.% #.% % % #.% #.% % % #.% #.% % % #.% #.% % % % % % % #.% % % #.% % % #.% #.% % % #.% #.% % % #.% #.% % % #.% #.% % % #.% % % % % #.% ",
+"% #.% % % #.% #.% % % #.% #.% % % % % #.% % % #.% #.% % % % % #.% % % % % #.% % % % % #.% % % #.% % % #.% % % % % % % #.% #.% % #.%.% #.% % % % % #.% #.% #.% #.% % % #.% #.% % % #.% #.% % % #.% #.% % % #.% #.% % % #.% #.% % % % % % % #.% % % #.% % % #.% #.% % % #.% #.% % % #.% %.#.% #.%.% #.% % % #.% % % % #.%.% ",
+"% $.#.#.#.$.% $.#.#.#.% % $.% % % % % $.% % % $.% $.#.#.#.% % $.#.#.#.% % $.%.#.#.$.% $.#.#.#.$.% % % $.% % % % % % % $.% $.#.#.%.% % $.% % % % % $.% % % $.% $.% % % $.% $.% % % $.% $.#.#.#.$.% $.#.% % $.% $.#.#.#.% % $.#.#.#.$.% % % $.% % % $.% % % $.% $.% % % $.% $.% % % $.% % %.#.%.% % $.#.#.#.$.% % %.#.%.% % ",
+"% #.% % % #.% #.% % % #.% #.% % % % % #.% % % #.% #.% % % % % #.% % % % % #.% % % #.% #.% % % #.% % % #.% % % % % % % #.% #.% % #.%.% #.% % % % % #.% % % #.% #.% % % #.% #.% % % #.% #.% % % % % #.% #.% #.% #.% % % #.% % % % % #.% % % #.% % % #.% % % #.% #.% % % #.% #.% #.% #.% %.#.% #.%.% % % % % #.% %.#.% % % % ",
+"% #.% % % #.% #.% % % #.% #.% % % % % #.% % % #.% #.% % % % % #.% % % % % #.% % % #.% #.% % % #.% % % #.% % % % % % % #.% #.% % % #.% #.% % % % % #.% % % #.% #.% % % #.% #.% % % #.% #.% % % % % #.% % #.#.% #.% % % #.% % % % % #.% % % #.% % % #.% % % #.% #.% % % #.% #.#.% #.#.% #.% % % #.% % % % % #.% #.% % % % % ",
+"% $.% % % $.% $.#.#.#.% % $.#.#.#.$.% #.#.#.#.% % $.#.#.#.$.% #.% % % % % $.#.#.#.$.% $.% % % $.% % % #.% % % $.#.#.#.$.% $.% % % $.% $.#.#.#.%.% $.% % % $.% #.% % % #.% $.#.#.#.$.% $.% % % % % $.#.#.#.$.% $.% % % $.% $.#.#.#.$.% % % $.% % % %.#.#.#.#.% % #.#.#.% % #.% % % #.% $.% % % #.% $.#.#.#.$.% $.#.#.#.$.% ",
 "% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % ",
 "% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %       % % % % % % % % ",
-"% % ........% % %  . . . .&.% &.........#.% &.........&.% &. . . . .&.% &.........&.% &.........#.% &.........&.% &.........#.% &.........#.% % % % %         % % ........% % % ........% % % % % % % ........% % % ........% %   % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % % $. . . .$.% ",
-"% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % % %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % ..% %         % ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       % $.% $.% $. .% ",
-"% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % % %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % ..% %         % ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       %  .$.% $.%  .% ",
-"% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % % %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % % % %         % ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       %  .% $.% $. .% ",
-"% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % % %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % % % %         % ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       %  .$.% $.% $.% ",
-"% &. . . . .&.% %  . . . .&.% &.........&.% &.........&.% &.........&.% &.........&.% &.........&.% %  . . . .&.% &.........&.% &.........&.% % % % %         % &. . . . .&.% &. . . . .&.% % % % % &. . . . .&.% &. . . . .&.%   % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % $. . . .$.% % ",
+"% % ........% % %  . . . .&.% &......... at .% &.........&.% &. . . . .&.% &.........&.% &......... at .% &.........&.% &......... at .% &......... at .% % % % %         % % ........% % % ........% % % % % % % ........% % % ........% %   % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % % #. . . .#.% ",
+"% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % % %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % ..% %         % ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       % #.% #.% #. .% ",
+"% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % % %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % ..% %         % ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       %  .#.% #.%  .% ",
+"% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % % %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % % % %         % ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       %  .% #.% #. .% ",
+"% ..% % % % ..%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..% ..% % % %  .% ..% % % %  .%  .% % % % ..% ..% % % % ..% ..% % % % ..% % % % %         % ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       %  .#.% #.% #.% ",
+"% &. . . . .&.% %  . . . .&.% &.........&.% &.........&.% &.........&.% &.........&.% &.........&.% %  . . . .&.% &.........&.% &.........&.% % % % %         % &. . . . .&.% &. . . . .&.% % % % % &. . . . .&.% &. . . . .&.%   % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % #. . . .#.% % ",
 "% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % % % %         % ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       %  .% % % %  .% ",
-"% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % % % %         % ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       % $.$.$.$.$. .% ",
-"% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % ..% %         % ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       % $.% % % $.$.% ",
-"% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % ..% %         % ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       % $.% % % $.$.% ",
-"% % ........% % %  . . . .&.% &.........&.% &.........&.% %  . . . .&.% &.........&.% &.........&.% %  . . . .&.% &.........&.% &.........&.% % % % %         % % ........% % % ........% % % % % % % ........% % % ........% %   % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % $.$.$.$.$.% % ",
+"% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % % % %         % ..% % % % ..% ..% % % % ..% % % % % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% % % % %  .% % % %  .%  .% % % %  .%       % #.#.#.#.#. .% ",
+"% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % ..% %         % ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       % #.% % % #.#.% ",
+"% ..% % % % ..%  .% % % % ..% ..% % % %  .%  .% % % % ..%  .% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% ..% % % % ..%  .% % % % ..% % ..% %         % ..% % % % ..% ..% % % % ..% % ..% % ..% % % % ..% ..% % % % ..%   %  .% % % %  .%  .% % % %  .% %  .% %  .% % % %  .%  .% % % %  .%       % #.% % % #.#.% ",
+"% % ........% % %  . . . .&.% &.........&.% &.........&.% %  . . . .&.% &.........&.% &.........&.% %  . . . .&.% &.........&.% &.........&.% % % % %         % % ........% % % ........% % % % % % % ........% % % ........% %   % %  . . . .% % %  . . . .% % % % % % %  . . . .% % %  . . . .% %       % #.#.#.#.#.% % ",
 "% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %       % % % % % % % % "};
diff --git a/wmacpi.c b/wmacpi.c
index 241eeb5..815cfb1 100644
--- a/wmacpi.c
+++ b/wmacpi.c
@@ -36,7 +36,7 @@
 #include "libacpi.h"
 #include "wmacpi.h"
 
-#define WMACPI_VER "2.2rc1"
+#define WMACPI_VER "2.2rc3"
 
 /* main pixmap */
 #ifdef LOW_COLOR
@@ -61,6 +61,7 @@ struct dockapp {
     int bell;			/* bell on critical low, or not? */
     int scroll;			/* scroll message text? */
     int scroll_reset;		/* reset the scrolling text */
+    int percent;
 };
 
 /* globals */
@@ -113,7 +114,7 @@ static void clear_time_display(void)
 /* set time display to -- -- */
 static void invalid_time_display(void)
 {
-    copy_xpm_area(122, 13, 31, 11, 7, 32);
+    copy_xpm_area(122, 14, 31, 11, 7, 32);
 }
 
 static void reset_scroll(void) {
@@ -195,7 +196,7 @@ 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 width = 51;		/* 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;
@@ -298,10 +299,18 @@ static void render_text(char *string)
     scroll_text();
 }
 
+static void clear_percentage(void)
+{
+  /* clear the number */
+  copy_xpm_area(95, 47, 21, 9, 37, 16);
+  /* clear the bar */
+  copy_xpm_area(66, 18, 54, 8, 5, 5);
+
+  dockapp->percent = -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
@@ -310,7 +319,7 @@ static void display_percentage(int percent)
     if (percent == -1)
 	percent = 0;
 
-    if (op == percent)
+    if (dockapp->percent == percent)
 	return;
 
     if (percent < 0)
@@ -318,6 +327,9 @@ static void display_percentage(int percent)
     if (percent > 100)
 	percent = 100;
 
+    if (dockapp->percent == -1)
+	copy_xpm_area(127, 28, 5, 7, 52, 17);
+
     if (percent < 100) {	/* 0 - 99 */
 	copy_xpm_area(95, 48, 8, 7, 37, 17);
 	if (percent >= 10)
@@ -325,17 +337,13 @@ static void display_percentage(int percent)
 	copy_xpm_area((percent % 10) * 6 + 67, 28, 5, 7, 46, 17);
     } else
 	copy_xpm_area(95, 37, 21, 9, 37, 16);	/* 100% */
-    op = percent;
+    dockapp->percent = percent;
 
     bar = (int)((float)percent / ratio);
 
-    if (bar == obar)
-	return;
-
     copy_xpm_area(66, 0, bar, 8, 5, 5);
     if (bar < 54)
 	copy_xpm_area(66 + bar, 18, 54 - bar, 8, bar + 5, 5);
-    obar = bar;
 }
 
 static void display_time(int minutes)
@@ -446,19 +454,12 @@ static void set_power_panel(global_t *globals)
 	}
     }
 
-    if (binfo->charge_state == CHARGE)
-	blink_power_glyph();
-
-    if ((binfo->state == CRIT) && (ap->power == BATT))
-	blink_battery_glyph();
+    if (globals->battery_count > 0) {
+	if (binfo->charge_state == CHARGE)
+	    blink_power_glyph();
 
-    if (binfo->state == HARD_CRIT) {
-	really_blink_battery_glyph();
-	/* we only do this here because it'd be obnoxious to 
-	 * do it anywhere else. */
-	if (dockapp->bell) {
-	    XBell(dockapp->display, 100);
-	}
+	if ((binfo->state == CRIT) && (ap->power == BATT))
+	    blink_battery_glyph();
     }
 }
 
@@ -489,6 +490,7 @@ void reset_scroll_speed(void) {
  * appropriate right now, and then decide within them. 
  */
 enum messages {
+    M_NB,	/* no batteries */
     M_NP,	/* not present */
     M_AC,	/* on ac power */
     M_CH,	/* battery charging */
@@ -505,6 +507,16 @@ static void set_message(global_t *globals)
     battery_t *binfo = globals->binfo;
     adapter_t *ap = &globals->adapter;
     
+    if (globals->battery_count == 0) {
+	if (state != M_NB) {
+	    state = M_NB;
+	    reset_scroll_speed();
+	    render_text("no batteries");
+	}
+
+	return;
+    }
+    
     /* battery not present case */
     if (!binfo->present) {
 	if (state != M_NP) {
@@ -533,12 +545,6 @@ static void set_message(global_t *globals)
 		scroll_faster(0.75);
 		render_text("critical low battery");
 	    }
-	} else if (binfo->state == HARD_CRIT) {
-	    if (state != M_HCB) {
-		state = M_HCB;
-		scroll_faster(0.5);
-		render_text("hard critical low battery");
-	    }
 	} else if (binfo->state == LOW) {
 	    if (state != M_LB) {
 		state = M_LB;
@@ -557,6 +563,11 @@ static void set_message(global_t *globals)
 
 void set_time_display(global_t *globals)
 {
+    if (globals->battery_count == 0) {
+        invalid_time_display();
+	return;
+    }
+
     if (globals->binfo->charge_state == CHARGE)
 	display_time(globals->binfo->charge_time);
     else if (globals->binfo->charge_state == DISCHARGE)
@@ -565,12 +576,17 @@ void set_time_display(global_t *globals)
 	invalid_time_display();
 }
 
+void clear_batt_id_area(void)
+{
+    copy_xpm_area(125, 40, 7, 11, 51, 32);
+}
+
 void set_batt_id_area(int bno)
 {
     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 dy = 32;		/* y coord of the target area */
     int sx = (bno + 1) * 7;	/* source x coord */
     int sy = 76;		/* source y coord */
     
@@ -628,6 +644,16 @@ void cli_wmacpi(global_t *globals, int samples)
     return;
 }
 
+battery_t *switch_battery(global_t *globals, int battno)
+{
+  globals->binfo = &batteries[battno];
+  pinfo("changing to monitor battery %s\n", globals->binfo->name);
+  set_batt_id_area(battno);
+  dockapp->update = 1;
+
+  return globals->binfo;
+}
+
 int main(int argc, char **argv)
 {
     char *display = NULL;
@@ -642,7 +668,7 @@ int main(int argc, char **argv)
     int scroll_count = 0;
     enum rtime_mode rt_mode = RT_RATE;
     int rt_forced = 0;
-    battery_t *binfo;
+    battery_t *binfo = NULL;
     global_t *globals;
 
     DAProgramOption options[] = {
@@ -717,8 +743,7 @@ int main(int argc, char **argv)
     globals->rt_forced = rt_forced;
 
     if (battery_no > globals->battery_count) {
-	pfatal("Battery %d not available for monitoring.\n", battery_no);
-	exit(1);
+	pinfo("Battery %d not available for monitoring.\n", battery_no);
     }
 
     /* check for cli mode */
@@ -744,13 +769,17 @@ int main(int argc, char **argv)
 
     /* get initial statistics */
     acquire_all_info(globals);
-    binfo = &batteries[battery_no];
-    globals->binfo = binfo;
-    pinfo("monitoring battery %s\n", binfo->name);
+
+    if (globals->battery_count > 0) {
+      binfo = &batteries[battery_no];
+      globals->binfo = binfo;
+      set_batt_id_area(battery_no);
+      pinfo("monitoring battery %s\n", binfo->name);
+    }
+
     clear_time_display();
     set_power_panel(globals);
     set_message(globals);
-    set_batt_id_area(battery_no);
 
     /* main loop */
     while (1) {
@@ -773,14 +802,14 @@ int main(int argc, char **argv)
 	    case ButtonPress:
 		break;
 	    case ButtonRelease:
+		if (globals->battery_count == 0)
+		    break;
+
 		/* cycle through the known batteries. */
 		battery_no++;
 		battery_no = battery_no % globals->battery_count;
-		globals->binfo = &batteries[battery_no];
-		binfo = globals->binfo;
-		pinfo("changing to monitor battery %s\n", binfo->name);
-		set_batt_id_area(battery_no);
-		dockapp->update = 1;
+
+		binfo = switch_battery(globals, battery_no);
 		break;
 	    case ClientMessage:
 		/* what /is/ this crap?
@@ -834,6 +863,20 @@ 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)) {
+	    if (globals->battery_count == 0) {
+	        batt_count = 0;
+
+	        reinit_batteries(globals);
+
+		/* battery appeared */
+		if (globals->battery_count > 0) {
+		    if (battery_no > globals->battery_count)
+		        battery_no = 0;
+		    
+		    binfo = switch_battery(globals, battery_no);
+		}
+	    }
+
 	    acquire_all_info(globals);
 
 	    /* we need to be able to reinitialise batteries and adapters, because
@@ -872,7 +915,13 @@ int main(int argc, char **argv)
 	set_time_display(globals);
 	set_power_panel(globals);
 	set_message(globals);
-	display_percentage(binfo->percentage);
+
+	if (globals->battery_count == 0) {
+	    clear_percentage();
+	    clear_batt_id_area();
+	} else 
+	    display_percentage(binfo->percentage);
+
 	scroll_text();
 
 	/* redraw_window, if anything changed - determined inside 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmacpi.git



More information about the Pkg-wmaker-commits mailing list