diff options
-rw-r--r-- | xbattext.c | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -44,8 +44,6 @@ /* low battery level */ #define ALERT 30 -void update(XtPointer, XtIntervalId *); - /* resources */ struct res { XmFontList font_list; @@ -82,12 +80,14 @@ enum { /* application state */ Arg wargs[10]; char *s; -int apmfd, alerting, charging; +int alerting, apmfd, charging, i; struct apm_power_info info; Widget toplevel, label; XmString xms; XtAppContext app_context; +void update(XtPointer, XtIntervalId *); + /* program start */ int main(int argc, char* argv[]) @@ -127,19 +127,14 @@ main(int argc, char* argv[]) void update(XtPointer client_data, XtIntervalId *t) { - int i; - /* reset temporary variables */ i = 0; change = SET_NONE; /* get battery info */ memset(&info, 0, sizeof(info)); - if (ioctl(apmfd, APM_IOC_GETPOWER, &info) == -1) { - fprintf(stderr, "ioctl APM_IOC_GETPOWER failed\n"); - sprintf(s, "?"); - goto end; - } + if (ioctl(apmfd, APM_IOC_GETPOWER, &info) == -1) + err(1, "ioctl"); /* put battery status into label */ sprintf(s, "%d%%", info.battery_life); |