From bab98314d8cf2b4d8ba5b0b018f654ba8729d0a0 Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Wed, 19 Sep 2018 16:41:07 +0930 Subject: added readme allows bormal time output set env variable 'binstatus' to 'dec' to output decimal time HH:MM. --- README.md | 12 ++++++++++++ binstatus.c | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 README.md 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 +#include #include #include #include @@ -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) { -- cgit v1.2.3