diff options
author | daniel-Jones <daniel@danieljon.es> | 2018-09-19 16:53:41 +0930 |
---|---|---|
committer | daniel-Jones <daniel@danieljon.es> | 2018-09-19 16:53:41 +0930 |
commit | 3bd31a22fb78954a67658a13b82344c896b15ac9 (patch) | |
tree | 858b5f931ca142d5850ee746e0f5a3270b9cba22 | |
parent | 024d14450abc9b9bdd47ae3a61f8664a5271553a (diff) | |
download | binstatus-3bd31a22fb78954a67658a13b82344c896b15ac9.tar.gz binstatus-3bd31a22fb78954a67658a13b82344c896b15ac9.zip |
fix segfault, woops. changed readme a bit
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | binstatus.c | 11 |
2 files changed, 7 insertions, 6 deletions
@@ -1,4 +1,4 @@ -By default this program will set your root windows name to the time in binary, however if you set the environment variable binstatus to 'dec' (export binstatus=dec) it will display the time as hh:mm. +By default this program will set your root windows name to the time in binary, however if you set the environment variable binstatus to 'dec' (export binstatus=dec) it will display the time as hh:mm. 'bin' is also a valid value, that will be the time in binary. Any other value will not output anything, dwm or your window manager may use its own string. compile: diff --git a/binstatus.c b/binstatus.c index 046e09e..c521677 100644 --- a/binstatus.c +++ b/binstatus.c @@ -43,15 +43,16 @@ void formatstring(char *status, int *time) { char *env = getenv("binstatus"); - if (strcmp(env, "dec") == 0) - { - snprintf(status, MAXLENGTH, "%02d:%02d", time[0], time[1]); - } - else + if (!env || strcmp(env, "bin") == 0) { + snprintf(status, MAXLENGTH, "%05d %06d", dectobin(time[0]), dectobin(time[1])); } + else if (strcmp(env, "dec") == 0) + { + snprintf(status, MAXLENGTH, "%02d:%02d", time[0], time[1]); + } } int |