aboutsummaryrefslogtreecommitdiff
path: root/xbattext.c
diff options
context:
space:
mode:
Diffstat (limited to 'xbattext.c')
-rw-r--r--xbattext.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/xbattext.c b/xbattext.c
index 9eecac7..4f56225 100644
--- a/xbattext.c
+++ b/xbattext.c
@@ -126,9 +126,11 @@ update(XtPointer client_data, XtIntervalId *t)
sprintf(s, "%d%%", info.battery_life);
xms = XmStringCreate(s, XmFONTLIST_DEFAULT_TAG);
+ /* set color and font depending on battery status */
i = 0;
XtSetArg(wargs[i], XmNlabelString, xms); i++;
+ /* check if the ac adapter has been plugged in */
if (!charge && info.ac_state == APM_AC_ON) {
charge = 1;
XtSetArg(wargs[i], XtNforeground, res.charge_foreground);
@@ -140,9 +142,10 @@ update(XtPointer client_data, XtIntervalId *t)
XtSetArg(wargs[i], XmNfontList, res.font_list);
i++;
}
- goto set; /* skip alert */
+ goto set; /* skip further checks */
}
+ /* check low battery */
#ifdef ALERT
if (!alert && info.battery_life < ALERT) {
alert = 1;
@@ -163,9 +166,10 @@ update(XtPointer client_data, XtIntervalId *t)
}
#endif
+ /* check if the ac adapter has been plugged out */
if (charge && info.ac_state != APM_AC_ON) {
charge = 0;
- if (i > 1) goto set; /* skip if alert already set */
+ if (i > 1) goto set; /* don't overwrite alert */
XtSetArg(wargs[i], XtNforeground, res.foreground);
i++;
if (res.font_list != NULL) {