Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
removed UPDATE_INTERVAL, it is neat to have it but removing it is a tradeoff worth...
[slstatus.git]
/
slstatus.c
diff --git
a/slstatus.c
b/slstatus.c
index
7337e4a
..
ab461c8
100644
(file)
--- a/
slstatus.c
+++ b/
slstatus.c
@@
-33,7
+33,6
@@
struct arg {
const char *args;
};
const char *args;
};
-static void setstatus(const char *);
static char *smprintf(const char *, ...);
static char *battery_perc(const char *);
static char *cpu_perc(void);
static char *smprintf(const char *, ...);
static char *battery_perc(const char *);
static char *cpu_perc(void);
@@
-64,14
+63,6
@@
static Display *dpy;
#include "config.h"
#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, ...)
{
static char *
smprintf(const char *fmt, ...)
{
@@
-156,7
+147,6
@@
cpu_perc(void)
fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &a[0], &a[1], &a[2], &a[3]);
fclose(fp);
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");
sleep(1);
fp = fopen("/proc/stat","r");
@@
-262,8
+252,7
@@
entropy(void)
static char *
gid(void)
{
static char *
gid(void)
{
- gid_t gid = getgid();
- return smprintf("%d", gid);
+ return smprintf("%d", getgid());
}
static char *
}
static char *
@@
-626,10
+615,6
@@
main(void)
struct arg argument;
dpy = XOpenDisplay(0x0);
struct arg argument;
dpy = XOpenDisplay(0x0);
- if (!dpy) {
- fprintf(stderr, "Cannot open display!\n");
- exit(1);
- }
for (;;) {
memset(status_string, 0, sizeof(status_string));
for (;;) {
memset(status_string, 0, sizeof(status_string));
@@
-649,10
+634,15
@@
main(void)
free(element);
}
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;
}
XCloseDisplay(dpy);
return 0;
}