diff options
author | Jan Wolff <janw@mailbox.org> | 2019-06-18 22:45:52 +0200 |
---|---|---|
committer | Jan Wolff <janw@mailbox.org> | 2019-06-18 22:45:52 +0200 |
commit | 8d9a38e0a90abaf2a1ef22db26cb5e4a79893948 (patch) | |
tree | 37adf779966282fc275e81dcc6a8c551206fcafc | |
parent | b2084f87893ee4753baafca0bd635385b837ab30 (diff) |
no longer rely on xsetroot, use Xlib directly
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | dwmstatus.c | 16 |
2 files changed, 17 insertions, 5 deletions
@@ -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(); |