Implement clockloop utility
authorSiraaj Khandkar <siraaj@khandkar.net>
Thu, 2 Apr 2020 20:21:48 +0000 (16:21 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Thu, 2 Apr 2020 22:02:53 +0000 (18:02 -0400)
.gitignore
Makefile
src/Makefile [new file with mode: 0644]
src/clockloop.c [new file with mode: 0644]

index 6713391..0118d7f 100644 (file)
@@ -1 +1,2 @@
+bin/
 deps/*/data
index b576a5c..4dd417a 100644 (file)
--- 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 (file)
index 0000000..9339427
--- /dev/null
@@ -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 (file)
index 0000000..c9e04de
--- /dev/null
@@ -0,0 +1,28 @@
+#include <time.h>
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include <ncurses.h>
+
+
+#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;
+}
This page took 0.022225 seconds and 4 git commands to generate.