summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Wolff <janw@mailbox.org>2019-06-18 22:45:52 +0200
committerJan Wolff <janw@mailbox.org>2019-06-18 22:45:52 +0200
commit8d9a38e0a90abaf2a1ef22db26cb5e4a79893948 (patch)
tree37adf779966282fc275e81dcc6a8c551206fcafc
parentb2084f87893ee4753baafca0bd635385b837ab30 (diff)
no longer rely on xsetroot, use Xlib directly
-rw-r--r--Makefile6
-rw-r--r--dwmstatus.c16
2 files changed, 17 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 6ea2a1f..87db407 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,15 @@
CC = gcc
CFLAGS = -std=c11 -Wall -Wextra
+X11INC = /usr/X11R6/include
+X11LIB = /usr/X11R6/lib
+LIBS = -L${X11LIB} -lX11
+INCLUDE = -I${X11INC}
OBJ = dwmstatus.o
BIN = dwmstatus
PREFIX = /usr/local
prog: $(OBJ)
- $(CC) $(CFLAGS) $(OBJ) -o $(BIN)
+ $(CC) $(CFLAGS) $(LIBS) $(INCLUDE) $(OBJ) -o $(BIN)
debug: CFLAGS += -DDEBUG
debug: prog
diff --git a/dwmstatus.c b/dwmstatus.c
index 5abf380..1d16bb8 100644
--- a/dwmstatus.c
+++ b/dwmstatus.c
@@ -5,19 +5,23 @@
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
+#include <X11/Xlib.h>
#include "config.h"
-const size_t blockc = sizeof(blockTypes) / sizeof(enum BlockType);
+static char status[STATUS_SIZE];
+static char status_tmp[STATUS_TMP_SIZE];
-char status[STATUS_SIZE];
-char status_tmp[STATUS_TMP_SIZE];
+static Display * dpy;
+static int screen;
+static Window root;
void print() {
#ifdef DEBUG
puts(status);
#else
- if(fork() == 0) execlp("xsetroot", "xsetroot", "-name", status, NULL);
+ XStoreName(dpy, root, status);
+ XFlush(dpy);
#endif
}
@@ -81,6 +85,10 @@ void update() {
}
int main() {
+ dpy = XOpenDisplay(NULL);
+ screen = DefaultScreen(dpy);
+ root = RootWindow(dpy, screen);
+
while(1) {
update();
print();