aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarstr\xf6m <john@ankarstrom.se>2021-06-01 21:00:23 +0200
committerJohn Ankarstr\xf6m <john@ankarstrom.se>2021-06-01 21:00:23 +0200
commitf7f8b4038409dda87fd840242d5949f26e8beb0b (patch)
tree965bcf648681d5ae7bded3dbd2019b456e44633f
parent55a3b1e88d5374ff2383b15bb20894d1f71025a3 (diff)
downloadxbattext-f7f8b4038409dda87fd840242d5949f26e8beb0b.tar.gz
Fix color change bug
I forgot to change the 4 to a 6 (strlen("black")+1).
-rw-r--r--xbattext.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/xbattext.c b/xbattext.c
index e1d2fbe..efa7aa4 100644
--- a/xbattext.c
+++ b/xbattext.c
@@ -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);