From a445cd3134656695f4f60c941ba85dea9a1821d2 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Thu, 19 Jan 2017 17:06:24 -0500 Subject: Add fuzzy clock --- .bin/clock.c | 28 ++++++++++++++++++++++++++++ install.sh | 1 + 2 files changed, 29 insertions(+) create mode 100755 .bin/clock.c diff --git a/.bin/clock.c b/.bin/clock.c new file mode 100755 index 00000000..9eb4dc23 --- /dev/null +++ b/.bin/clock.c @@ -0,0 +1,28 @@ +#if 0 +exec cc -Wall -Wextra -pedantic $@ -o $(dirname $0)/clock $0 +#endif + +#include +#include +#include +#include + +int main() { + time_t timestamp = time(NULL); + if (timestamp < 0) err(EX_OSERR, "time"); + + struct tm *clock = localtime(×tamp); + if (!clock) err(EX_OSERR, "localtime"); + + switch ((clock->tm_min + 5) / 10) { + case 0: printf("...%02d...\n", clock->tm_hour); break; + case 1: printf("..%02d....\n", clock->tm_hour); break; + case 2: printf(".%02d.....\n", clock->tm_hour); break; + case 3: printf("%02d....%02d\n", clock->tm_hour, clock->tm_hour + 1); break; + case 4: printf(".....%02d.\n", clock->tm_hour + 1); break; + case 5: printf("....%02d..\n", clock->tm_hour + 1); break; + case 6: printf("...%02d...\n", clock->tm_hour + 1); break; + } + + return 0; +} diff --git a/install.sh b/install.sh index 3c0c5ed3..7a939866 100755 --- a/install.sh +++ b/install.sh @@ -26,6 +26,7 @@ if [ -d ~/Library ]; then link Library/Keyboard\ Layouts/Programmer.keylayout fi +link .bin/clock.c link .bin/jrp.c link .bin/manpager link .bin/pbcopy.c -- cgit 1.4.1