diff options
author | June McEnroe <june@causal.agency> | 2017-06-10 16:49:51 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2017-06-10 16:49:51 -0400 |
commit | 6ff956880b8dde199fe9ac1314e43b66e0046f71 (patch) | |
tree | a35a9957f67cedd45fcf2428f451944c38747ded /home/.bin/clock.c | |
parent | Remove Programming keyboard layout (diff) | |
download | src-6ff956880b8dde199fe9ac1314e43b66e0046f71.tar.gz src-6ff956880b8dde199fe9ac1314e43b66e0046f71.zip |
Move actual dotfiles into home directory
Diffstat (limited to 'home/.bin/clock.c')
-rwxr-xr-x | home/.bin/clock.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/home/.bin/clock.c b/home/.bin/clock.c new file mode 100755 index 00000000..288884d8 --- /dev/null +++ b/home/.bin/clock.c @@ -0,0 +1,33 @@ +#if 0 +exec cc -Wall -Wextra -pedantic $@ -o $(dirname $0)/clock $0 +#endif + +// Fuzzy clock for display in tmux. + +#include <time.h> +#include <stdio.h> +#include <sysexits.h> +#include <err.h> + +int main() { + time_t ts = time(NULL); + if (ts < 0) err(EX_OSERR, "time"); + + struct tm *time = localtime(&ts); + if (!time) err(EX_OSERR, "localtime"); + + int hour = time->tm_hour; + int next = (hour + 1) % 24; + + switch ((time->tm_min + 5) / 10) { + case 0: printf("..%02d..\n", hour); break; + case 1: printf(".%02d...\n", hour); break; + case 2: printf("%02d....\n", hour); break; + case 3: printf("%d....%d\n", hour % 10, next / 10); break; + case 4: printf("....%02d\n", next); break; + case 5: printf("...%02d.\n", next); break; + case 6: printf("..%02d..\n", next); break; + } + + return EX_OK; +} |