diff options
author | John Ankarstr\xf6m <john@ankarstrom.se> | 2021-06-01 21:00:23 +0200 |
---|---|---|
committer | John Ankarstr\xf6m <john@ankarstrom.se> | 2021-06-01 21:00:23 +0200 |
commit | f7f8b4038409dda87fd840242d5949f26e8beb0b (patch) | |
tree | 965bcf648681d5ae7bded3dbd2019b456e44633f | |
parent | 55a3b1e88d5374ff2383b15bb20894d1f71025a3 (diff) | |
download | xbattext-f7f8b4038409dda87fd840242d5949f26e8beb0b.tar.gz |
Fix color change bug
I forgot to change the 4 to a 6 (strlen("black")+1).
-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); |