summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel-Jones <daniel@danieljon.es>2018-09-19 17:40:40 +0930
committerdaniel-Jones <daniel@danieljon.es>2018-09-19 17:40:40 +0930
commit2000b4f849c0407f8955ba217d4d425a4da54171 (patch)
treec0e3a7f91ea8929e1aea0be58d6597a9ee33bea2
parent3bd31a22fb78954a67658a13b82344c896b15ac9 (diff)
downloadbinstatus-2000b4f849c0407f8955ba217d4d425a4da54171.tar.gz
binstatus-2000b4f849c0407f8955ba217d4d425a4da54171.zip
removed rnv var usage, added -d
-rw-r--r--README.md2
-rw-r--r--binstatus.c18
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 <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];