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 | |
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.
-rw-r--r-- | README.md | 12 | ||||
-rw-r--r-- | binstatus.c | 19 |
2 files changed, 29 insertions, 2 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..fa66640 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +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. + + +compile: +````cc binstatus.c -lX11 -o binstatus```` + + +run: +````./binstatus &```` + + +You may prefer to put this in your .xinitrc file. 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) { |