diff options
-rw-r--r-- | xbattext.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -29,7 +29,7 @@ #include <Xm/Xm.h> /* interval in seconds */ -#define INTERVAL 30 +#define INTERVAL 15 /* low battery level */ #define ALERT 30 @@ -98,22 +98,29 @@ update(XtPointer client_data, XtIntervalId *t) /* put battery status into label */ sprintf(s, "%d%%", info.battery_life); str = XmStringCreate(s, XmFONTLIST_DEFAULT_TAG); - XtSetArg(wargs[0], XmNlabelString, str); - XtSetValues(label, wargs, 1); - XmStringFree(str); - /* change color if low battery */ #ifdef ALERT if (!alert && info.battery_life < ALERT) { XtVaSetValues(label, - XtVaTypedArg, XmNforeground, XmRString, "red", 4); + XmNlabelString, str, + XtVaTypedArg, XtNforeground, XtRString, "red", 4, + NULL); alert = 1; - } else if (alert && info.battery_life >= ALERT) { + } + else if (alert && info.battery_life > ALERT) { XtVaSetValues(label, - XtVaTypedArg, XmNforeground, XmRString, "black", 4); + XmNlabelString, str, + XtVaTypedArg, XtNforeground, XtRString, "black", 6, + NULL); alert = 0; } + else #endif + XtVaSetValues(label, + XmNlabelString, str, + NULL); + + XmStringFree(str); /* add new timer */ end: timer = XtAppAddTimeOut(app_context, INTERVAL * 1000, update, toplevel); |