diff options
author | daniel-Jones <daniel@danieljon.es> | 2018-09-19 17:40:40 +0930 |
---|---|---|
committer | daniel-Jones <daniel@danieljon.es> | 2018-09-19 17:40:40 +0930 |
commit | 2000b4f849c0407f8955ba217d4d425a4da54171 (patch) | |
tree | c0e3a7f91ea8929e1aea0be58d6597a9ee33bea2 /binstatus.c | |
parent | 3bd31a22fb78954a67658a13b82344c896b15ac9 (diff) | |
download | binstatus-2000b4f849c0407f8955ba217d4d425a4da54171.tar.gz binstatus-2000b4f849c0407f8955ba217d4d425a4da54171.zip |
removed rnv var usage, added -d
Diffstat (limited to 'binstatus.c')
-rw-r--r-- | binstatus.c | 18 |
1 files changed, 14 insertions, 4 deletions
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]; |