From: Siraaj Khandkar Date: Thu, 2 Apr 2020 20:21:48 +0000 (-0400) Subject: Implement clockloop utility X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=de7ac8e9b85eaec159496976fc65eeec6c332816;p=khome.git Implement clockloop utility --- diff --git a/.gitignore b/.gitignore index 6713391..0118d7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +bin/ deps/*/data diff --git a/Makefile b/Makefile index b576a5c..4dd417a 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,8 @@ default: @echo '================================================================================' @exit 1 -home: mpdconf +home: mpdconf compiled + @cp -Rp bin $(HOME)/ @cp -Rp home/bin $(HOME)/ @cp -Rp home/lib $(HOME)/ @cp home/.compton.conf $(HOME)/ @@ -43,6 +44,11 @@ mpdconf: @mkdir -p ~/var/run/mpd @cp home/.mpdconf $(HOME)/ +compiled: + mkdir -p bin + cd src && make + mv src/clockloop bin/ + font_cache: @fc-cache -fv diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..9339427 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,10 @@ +CPPFLAGS := -D_POSIX_C_SOURCE=200809L +CFLAGS := -std=c99 -Wall -Wextra +LDLIBS := -lncurses + +.PHONY: build clean + +build: clockloop + +clean: + rm -f clockloop diff --git a/src/clockloop.c b/src/clockloop.c new file mode 100644 index 0000000..c9e04de --- /dev/null +++ b/src/clockloop.c @@ -0,0 +1,28 @@ +#include + +#include +#include + +#include + + +#define BS 50 + + +int +main() +{ + time_t t; + char buf[BS]; + + initscr(); + timeout(0); + while (getch() == -1) { + t = time(NULL); + strftime(buf, BS, "%A %Y-%m-%d %H:%M:%S", localtime(&t)); + mvprintw(0, 0, "%s", buf); + refresh(); + } + endwin(); + return 0; +}