From 3bd31a22fb78954a67658a13b82344c896b15ac9 Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Wed, 19 Sep 2018 16:53:41 +0930 Subject: fix segfault, woops. changed readme a bit --- README.md | 2 +- binstatus.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6fea9ce..0e198bd 100644 --- a/README.md +++ b/README.md @@ -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 -- cgit v1.2.3