diff options
author | daniel-Jones <daniel@danieljon.es> | 2018-09-19 16:41:07 +0930 |
---|---|---|
committer | daniel-Jones <daniel@danieljon.es> | 2018-09-19 16:41:07 +0930 |
commit | bab98314d8cf2b4d8ba5b0b018f654ba8729d0a0 (patch) | |
tree | 087e8a296c46336dea0e9702127df8c2200a59de /binstatus.c | |
parent | 357fc5ac5076231584e02eaa6e687c655a66c482 (diff) | |
download | binstatus-bab98314d8cf2b4d8ba5b0b018f654ba8729d0a0.tar.gz binstatus-bab98314d8cf2b4d8ba5b0b018f654ba8729d0a0.zip |
added readme allows bormal time output
set env variable 'binstatus' to 'dec' to output decimal time HH:MM.
Diffstat (limited to 'binstatus.c')
-rw-r--r-- | binstatus.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/binstatus.c b/binstatus.c index eabaf3c..1b88afb 100644 --- a/binstatus.c +++ b/binstatus.c @@ -14,6 +14,7 @@ */ #include <stdio.h> +#include <string.h> #include <stdlib.h> #include <unistd.h> #include <time.h> @@ -38,6 +39,21 @@ gettime(int *store) store[1] = tm->tm_min; } +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 + { + sprintf(status, "%05d %06d", dectobin(time[0]), + dectobin(time[1])); + } +} + int main(void) { @@ -53,8 +69,7 @@ main(void) while (1) { gettime(time); - sprintf(status, "%05d %06d", dectobin(time[0]), - dectobin(time[1])); + formatstring(status, time); int res = XStoreName(dsp, DefaultRootWindow(dsp), status); if (res == BadAlloc) { |