X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=blobdiff_plain;f=cprogs%2Fxacpi-simple.c;h=f2ba491d93adbc41d8773eedf77b4564f90ece13;hp=6328e5b9e0efaa80200a2e8aeb4b3a979fe8ba41;hb=6f9f49dbd62f0889fbbbbc249d1ae33f4e91269e;hpb=730369898ed4160801d3ebb3c72557b5a4a0d098 diff --git a/cprogs/xacpi-simple.c b/cprogs/xacpi-simple.c index 6328e5b..f2ba491 100644 --- a/cprogs/xacpi-simple.c +++ b/cprogs/xacpi-simple.c @@ -1,20 +1,16 @@ -/* todo - old way of doing alarm -*/ - /* * display outputs, per line: * - * Remaining: | Empty: | Degraded: - * blue | black | dimgrey discharging - * green | black | dimgrey charging - * cyan | black | dimgrey charged - * grey | black | dimgrey charging&discharching! - * darkcyan | black | dimgrey none of the above - * blue | red | dimgrey discharging - low! - * green | red | dimgrey charging - low - * cyan | red | dimgrey charged - low [1] - * grey | red | dimgrey charging&discharching, low [1] + * Remaining: | Empty: | Degraded: + * blue | black | dimgrey discharging + * green | black | dimgrey charging + * cyan | black | dimgrey charged + * grey | black | dimgrey charging&discharching! + * lightgrey | black | dimgrey none of the above + * blue | red | dimgrey discharging - low! + * green | red | dimgrey charging - low + * cyan | red | dimgrey charged - low [1] + * grey | red | dimgrey charging&discharching, low [1] * ... darkgreen ... no batteries present * ... yellow ... error * @@ -66,7 +62,7 @@ #define TIMEOUT_ONERROR 3333 /* milliseconds */ static const char program_name[]= "xacpi-simple"; -static int debug; +static int debug, alarmlevel; /*---------- general utility stuff and declarations ----------*/ @@ -82,7 +78,7 @@ typedef uint64_t value; typedef struct fileinfo fileinfo; typedef int parser(const fileinfo*); -static parser parse_uevent, parse_separate; +static parser parse_uevent; struct fileinfo { const char *filename; @@ -135,7 +131,8 @@ typedef struct batinfo_field { #define TYPE_BOTH 100 /* Except this is a magic invalid value. */ #define SEPARATE_QUANTITY_FIELDS(_) \ - _(alarm, BATTERY, "alarm", "0", "1") + /* See commit ec6f5f0be800bc5f2a27046833dba04e0c67ffac for + the code needed to use this */ #define ALL_DIRECT_VARS(_) \ @@ -156,7 +153,6 @@ typedef struct batinfo_field { #define ALL_PLAIN_ACCUMULATE_FIELDS(_) \ UEVENT_ESSENTIAL_QUANTITY_FIELDS(_) \ - UEVENT_ENUM_FIELDS(_) \ SEPARATE_QUANTITY_FIELDS(_) #define ALL_ACCUMULATE_FIELDS(_) \ @@ -260,11 +256,6 @@ static int parse_value(const fileinfo *cfile, const batinfo_field *field) { return 0; } -static int parse_separate(const fileinfo *cfile) { - batlinevalue = batlinebuf; - return parse_value(cfile, cfile->extra); -} - static int parse_uevent(const fileinfo *cfile) { char *equals= strchr(batlinebuf,'='); if (!equals) @@ -359,18 +350,21 @@ ALL_NEEDED_FIELDS(V_NEEDED) /* These next three variables are the results of the charging state */ static unsigned charging_mask; /* 1u<lastfg= gcv.foreground= pix_white; + gc_r->lastfg= gcv.foreground= pix_equilibrium; gc_r->gc= XCreateGC(disp,win, GCFunction|GCLineWidth|GCForeground, &gcv); } @@ -716,15 +724,15 @@ static void initgraphics(int argc, char **argv) { pos_x,pos_y,width,height,0,0,0); cmap= DefaultColormap(disp,screen); -#define C(c,u) colour(&pix_##c, #u "Color"); +#define C(c,u) colour(&pix_##u, #u "Color"); #define GC(g) initgc(&gc_##g); COLOURS #undef C #undef GC - r= XSetWindowBackground(disp,win,pix_dimgrey); + r= XSetWindowBackground(disp,win,pix_degraded); if (!r) fail("init set background"); - lastbackground= pix_dimgrey; + lastbackground= pix_degraded; normal_hints->flags= PWinGravity; normal_hints->win_gravity= gravity; @@ -755,15 +763,9 @@ static void refresh(void) { static void newgeometry(void) { int dummy; - unsigned int udummy, gotwidth, gotheight; Window dummyw; - XGetGeometry(disp,win, &dummyw,&dummy,&dummy, &gotwidth,&gotheight, - &udummy,&udummy); - assert(gotwidth < INT_MAX); - assert(gotheight < INT_MAX); - width = gotwidth; - height = gotheight; + XGetGeometry(disp,win, &dummyw,&dummy,&dummy, &width,&height, &dummy,&dummy); } static void eventloop(void) {