all repos — slstatus @ 1b65dec3064ecc3f317cbe79314a36eb7c95706b

my build of slstatus (tools.suckless.org/slstatus/)

fixed some small things (update_interval) interferes with get_cpu_usage() and reordered)
Aaron Marcher info@nulltime.net
Thu, 10 Mar 2016 14:59:37 +0100
commit

1b65dec3064ecc3f317cbe79314a36eb7c95706b

parent

e046ee18f92569ca67b323757421c5e9b6637d0d

2 files changed, 24 insertions(+), 20 deletions(-)

jump to
M config.def.hconfig.def.h

@@ -17,8 +17,8 @@

/* time */ static const char timeformat[] = "%y-%m-%d %H:%M:%S"; -/* bar update interval in seconds */ -static unsigned int update_interval = 10; +/* bar update interval in seconds (smallest value = 1) */ +static unsigned int update_interval = 1; /* statusbar Possible arguments:
M slstatus.cslstatus.c

@@ -16,9 +16,15 @@

/* local libraries */ #include "config.h" +/* check file macro */ +#define CHECK_FILE(X,Y) do { \ + if (stat(X,&Y) < 0) return -1; \ + if (!S_ISREG(Y.st_mode)) return -1; \ +} while (0); + /* functions */ -void setstatus(char *str); int config_check(); +void setstatus(char *str); char *smprintf(char *fmt, ...); char *get_battery(); char *get_cpu_temperature();

@@ -31,6 +37,17 @@

/* global variables */ static Display *dpy; +/* check configured paths */ +int +config_check() +{ + struct stat fs; + CHECK_FILE(batterynowfile, fs); + CHECK_FILE(batteryfullfile, fs); + CHECK_FILE(tempfile, fs); + return 0; +} + /* set statusbar (WM_NAME) */ void setstatus(char *str)

@@ -51,22 +68,6 @@ return NULL;

va_end(fmtargs); return ret; -} - -#define CHECK_FILE(X,Y) do { \ - if (stat(X,&Y) < 0) return -1; \ - if (!S_ISREG(Y.st_mode)) return -1; \ -} while (0); - -/* check configured paths */ -int -config_check() -{ - struct stat fs; - CHECK_FILE(batterynowfile, fs); - CHECK_FILE(batteryfullfile, fs); - CHECK_FILE(tempfile, fs); - return 0; } /* battery percentage */

@@ -339,6 +340,7 @@ if (config_check() < 0) {

fprintf(stderr, "Config error, please check paths and recompile\n"); exit(1); } + /* open display */ if (!(dpy = XOpenDisplay(0x0))) { fprintf(stderr, "Cannot open display!\n");

@@ -368,7 +370,9 @@ free(datetime);

free(ram_usage); free(volume); free(wifi_signal); - sleep(update_interval); + + /* wait, "update_interval - 1" because of get_cpu_usage() which uses 1 second */ + sleep(update_interval -1); } /* close display */