From 2000b4f849c0407f8955ba217d4d425a4da54171 Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Wed, 19 Sep 2018 17:40:40 +0930 Subject: removed rnv var usage, added -d --- README.md | 2 +- binstatus.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0e198bd..05be93e 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. '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 #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]; -- cgit v1.2.3