diff options
-rw-r--r-- | xbattext.c | 31 |
1 files changed, 11 insertions, 20 deletions
@@ -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); } |