diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | xbattext.c | 21 |
2 files changed, 20 insertions, 4 deletions
@@ -6,3 +6,6 @@ xbattext: xbattext.c install: xbattext install xbattext /usr/local/bin + +upload: xbattext.c + scp xbattext.c root@ankarstrom.se:/var/www/img/htdocs/xbattext.c @@ -34,7 +34,7 @@ #include <Xm/Label.h> /* interval in seconds */ -#define INTERVAL 15 +#define INTERVAL 10 /* low battery level */ #define ALERT 30 @@ -68,7 +68,7 @@ static XtResource res_opts[] = { /* application state */ Arg wargs[10]; char *s; -int apmfd, alert; +int apmfd, alert, charge; struct apm_power_info info; Widget toplevel, label; XmFontList font_list; @@ -105,6 +105,7 @@ main(int argc, char* argv[]) XmNlabel, "", NULL); alert = 0; + charge = 0; update(NULL, &timer); XtRealizeWidget(toplevel); @@ -138,7 +139,8 @@ update(XtPointer client_data, XtIntervalId *t) i = 0; XtSetArg(wargs[i], XmNlabelString, xms); i++; - if (info.ac_state == APM_AC_ON) { + if (!charge && info.ac_state == APM_AC_ON) { + charge = 1; XtSetArg(wargs[i], XtNforeground, res.charge_foreground); i++; if (res.charge_font_list != NULL) { @@ -148,7 +150,7 @@ update(XtPointer client_data, XtIntervalId *t) XtSetArg(wargs[i], XmNfontList, res.font_list); i++; } - goto set; + goto set; /* skip alert */ } #ifdef ALERT @@ -171,6 +173,17 @@ update(XtPointer client_data, XtIntervalId *t) } #endif + if (charge && info.ac_state != APM_AC_ON) { + charge = 0; + if (i > 1) goto set; /* skip if alert already set */ + XtSetArg(wargs[i], XtNforeground, res.foreground); + i++; + if (res.font_list != NULL) { + XtSetArg(wargs[i], XmNfontList, res.font_list); + i++; + } + } + set: XtSetValues(label, wargs, i); XmStringFree(xms); |