diff options
-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) { |