diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | binstatus.c | 18 |
2 files changed, 15 insertions, 5 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. '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. +By default this program will set your root windows name to the time in binary, however if you run with -d it will display the time in decimal (HH:MM). compile: diff --git a/binstatus.c b/binstatus.c index c521677..ca384f1 100644 --- a/binstatus.c +++ b/binstatus.c @@ -21,6 +21,7 @@ #include <X11/Xlib.h> #define MAXLENGTH 256 +int binary = 1; /* 0 = decimal display, 1 = binary display */ int dectobin(int dec) @@ -42,22 +43,31 @@ gettime(int *store) void formatstring(char *status, int *time) { - char *env = getenv("binstatus"); - if (!env || strcmp(env, "bin") == 0) + if (binary) { snprintf(status, MAXLENGTH, "%05d %06d", dectobin(time[0]), dectobin(time[1])); } - else if (strcmp(env, "dec") == 0) + else { snprintf(status, MAXLENGTH, "%02d:%02d", time[0], time[1]); } } int -main(void) +main(int argc, char *argv[]) { + if (argc >= 2) + { + if (strcmp(argv[1], "-d") == 0) + binary = 0; + else + { + printf("usage: %s [-b]\n", argv[0]); + exit(EXIT_SUCCESS); + } + } int exitflag = EXIT_SUCCESS; char status[MAXLENGTH]; int time[2]; |