const char *args;
};
-static void setstatus(const char *);
static char *smprintf(const char *, ...);
static char *battery_perc(const char *);
static char *cpu_perc(void);
#include "config.h"
-static void
-setstatus(const char *str)
-{
- /* set WM_NAME via X11 */
- XStoreName(dpy, DefaultRootWindow(dpy), str);
- XSync(dpy, False);
-}
-
static char *
smprintf(const char *fmt, ...)
{
fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &a[0], &a[1], &a[2], &a[3]);
fclose(fp);
- /* wait a second (for avg values) */
sleep(1);
fp = fopen("/proc/stat","r");
static char *
gid(void)
{
- gid_t gid = getgid();
- return smprintf("%d", gid);
+ return smprintf("%d", getgid());
}
static char *
struct arg argument;
dpy = XOpenDisplay(0x0);
- if (!dpy) {
- fprintf(stderr, "Cannot open display!\n");
- exit(1);
- }
for (;;) {
memset(status_string, 0, sizeof(status_string));
free(element);
}
- setstatus(status_string);
- sleep(UPDATE_INTERVAL -1);
+ XStoreName(dpy, DefaultRootWindow(dpy), status_string);
+ XSync(dpy, False);
}
+ /* NOT REACHED */
+ /*
+ * TODO: find out a way to exit successfully
+ * to prevent memory leaks
+ */
XCloseDisplay(dpy);
return 0;
}