aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarstr\xf6m <john@ankarstrom.se>2021-06-03 00:46:01 +0200
committerJohn Ankarstr\xf6m <john@ankarstrom.se>2021-06-03 00:46:01 +0200
commitd510f2da913d670df38016328c9fdf4a2e837318 (patch)
treead3beb8b58ad17767c6803eb245c718be2043255
parent530e9d71c3c7e93952921a066b2e903bfe55ff2a (diff)
downloadxbattext-d510f2da913d670df38016328c9fdf4a2e837318.tar.gz
Stop trying to remove timeout
It is apparently unnecessary.
-rw-r--r--xbattext.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/xbattext.c b/xbattext.c
index 3abbb54..9eecac7 100644
--- a/xbattext.c
+++ b/xbattext.c
@@ -42,7 +42,7 @@
void update(XtPointer, XtIntervalId *);
/* resources */
-struct _res {
+struct res {
XmFontList font_list;
XmFontList alert_font_list;
XmFontList charge_font_list;
@@ -52,17 +52,17 @@ struct _res {
} res;
static XtResource res_opts[] = {
{"fontList", "FontList", XmRFontList, sizeof(XmFontList),
- XtOffset(struct _res*, font_list), XtRImmediate, (caddr_t)NULL},
+ XtOffset(struct res*, font_list), XtRImmediate, (caddr_t)NULL},
{"alertFontList", "AlertFontList", XmRFontList, sizeof(XmFontList),
- XtOffset(struct _res*, alert_font_list), XtRImmediate, (caddr_t)NULL},
+ XtOffset(struct res*, alert_font_list), XtRImmediate, (caddr_t)NULL},
{"chargeFontList", "ChargeFontList", XmRFontList, sizeof(XmFontList),
- XtOffset(struct _res*, charge_font_list), XtRImmediate, (caddr_t)NULL},
+ XtOffset(struct res*, charge_font_list), XtRImmediate, (caddr_t)NULL},
{"foreground", "foreground", XmRPixel, sizeof(Pixel),
- XtOffset(struct _res*, foreground), XtRImmediate, (caddr_t)NULL},
+ XtOffset(struct res*, foreground), XtRImmediate, (caddr_t)NULL},
{"alertForeground", "AlertForeground", XmRPixel, sizeof(Pixel),
- XtOffset(struct _res*, alert_foreground), XtRImmediate, (caddr_t)NULL},
+ XtOffset(struct res*, alert_foreground), XtRImmediate, (caddr_t)NULL},
{"chargeForeground", "ChargeForeground", XmRPixel, sizeof(Pixel),
- XtOffset(struct _res*, charge_foreground), XtRImmediate, (caddr_t)NULL},
+ XtOffset(struct res*, charge_foreground), XtRImmediate, (caddr_t)NULL},
};
/* application state */
@@ -73,7 +73,6 @@ struct apm_power_info info;
Widget toplevel, label;
XmString xms;
XtAppContext app_context;
-XtIntervalId timer = 0;
int
main(int argc, char* argv[])
@@ -86,27 +85,25 @@ main(int argc, char* argv[])
NULL,
NULL);
- if ((apmfd = open("/dev/apm", O_RDONLY, 0755)) == -1)
+ if ((apmfd = open("/dev/apm", O_RDONLY)) == -1)
err(1, "open");
if ((s = malloc(5*sizeof(char))) == NULL)
err(1, "malloc");
- XtSetLanguageProc(NULL, NULL, NULL);
-
/* load application resources */
XtGetApplicationResources(toplevel,
&res, res_opts, XtNumber(res_opts), NULL, 0);
/* create motif label */
- label = XtVaCreateManagedWidget("text",
+ label = XtVaCreateManagedWidget("label",
xmLabelWidgetClass, toplevel,
XmNlabel, "",
NULL);
alert = 0;
charge = 0;
- update(NULL, &timer);
+ update(NULL, NULL);
XtRealizeWidget(toplevel);
XtAppMainLoop(app_context);
}
@@ -117,12 +114,6 @@ update(XtPointer client_data, XtIntervalId *t)
{
int i;
- /* remove current timer */
- if (t == NULL && timer) {
- XtRemoveTimeOut(timer);
- timer = 0;
- }
-
/* get battery info */
memset(&info, 0, sizeof(info));
if (ioctl(apmfd, APM_IOC_GETPOWER, &info) == -1) {
@@ -187,5 +178,5 @@ set: XtSetValues(label, wargs, i);
XmStringFree(xms);
/* add new timer */
-end: timer = XtAppAddTimeOut(app_context, INTERVAL * 1000, update, toplevel);
+end: XtAppAddTimeOut(app_context, INTERVAL * 1000, update, NULL);
}