summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Wolff <janw@mailbox.org>2019-06-16 22:22:00 +0200
committerJan Wolff <janw@mailbox.org>2019-06-16 22:23:14 +0200
commit17abaa8fbae9a32ea2d7e7cf801ea94153abe7ea (patch)
treeea16b269d28c70b3561a2791378f3322584c4529
initial commit
-rw-r--r--LICENSE.md18
-rw-r--r--Makefile30
-rw-r--r--README.md3
-rw-r--r--dwmstatus.c29
4 files changed, 80 insertions, 0 deletions
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..6ed8478
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,18 @@
+Copyright (c) 2019 Jan Wolff
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..86b0ef0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,30 @@
+CC = gcc
+CFLAGS = -std=c11 -Wall -Wextra
+OBJ = dwmstatus.o
+BIN = dwmstatus
+PREFIX = /usr/local
+
+prog: $(OBJ)
+ $(CC) $(CFLAGS) $(OBJ) -o $(BIN)
+
+debug: CFLAGS += -DDEBUG -g -fsanitize=address -fsanitize=leak
+debug: prog
+
+%.o: %.c
+ $(CC) $(INCLUDE) $(CFLAGS) -c $<
+
+clean:
+ rm *.o
+ cd ..
+ rm $(BIN)
+
+install: prog
+ mkdir -p ${PREFIX}/bin
+ cp -f dwmstatus ${PREFIX}/bin
+ chmod 755 ${PREFIX}/bin/dwmstatus
+
+uninstall:
+ rm -f ${PREFIX}/bin/dwmstatus
+
+
+.PHONY: clean
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..875ec92
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+# dwmstatus
+
+status bar helper for dwm. maybe i'll add some fancy stuff to this
diff --git a/dwmstatus.c b/dwmstatus.c
new file mode 100644
index 0000000..47f8da0
--- /dev/null
+++ b/dwmstatus.c
@@ -0,0 +1,29 @@
+#include <time.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define STATUS_SIZE 256
+char status[STATUS_SIZE];
+
+void print() {
+#ifdef DEBUG
+ puts(status);
+#else
+ if(fork() == 0) execlp("xsetroot", "xsetroot", "-name", status, NULL);
+#endif
+}
+
+void update() {
+ time_t t = time(NULL);
+ struct tm * tm = localtime(&t);
+ strftime(status, STATUS_SIZE, "%F %H:%M", tm);
+}
+
+int main() {
+ while(1) {
+ update();
+ print();
+ sleep(60);
+ }
+}