From f972a39b880bc2a631c3804b6c9b41faeb9a3898 Mon Sep 17 00:00:00 2001 From: stupidcomputer Date: Tue, 26 Nov 2024 15:36:42 -0600 Subject: [PATCH] add dwm-setstatus.c --- Makefile | 5 ++++- dwm-setstatus.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 dwm-setstatus.c diff --git a/Makefile b/Makefile index ffa69b4..29d53d7 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ include config.mk SRC = drw.c dwm.c util.c OBJ = ${SRC:.c=.o} -all: dwm +all: dwm dwm-setstatus .c.o: ${CC} -c ${CFLAGS} $< @@ -19,6 +19,9 @@ config.h: dwm: ${OBJ} ${CC} -o $@ ${OBJ} ${LDFLAGS} +dwm-setstatus: + ${CC} -o $@ dwm-setstatus.c ${LDFLAGS} + clean: rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz diff --git a/dwm-setstatus.c b/dwm-setstatus.c new file mode 100644 index 0000000..1e1b1a8 --- /dev/null +++ b/dwm-setstatus.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include + +int main(int argc, char * argv[]) +{ + Display * dpy = NULL; + Window win = 0; + size_t length = 0; + ssize_t bytes_read = 0; + char * input = NULL; + + dpy = XOpenDisplay(getenv("DISPLAY")); + if (dpy == NULL) + { + fprintf(stderr, "Can't open display, exiting.\n"); + exit(1); + } + win = DefaultRootWindow(dpy); + + while ((bytes_read = getline(&input, &length, stdin)) != EOF) + { + input[strlen(input) - 1] = '\0'; + XStoreName(dpy, win, input); + XFlush(dpy); + } + free(input); + return 0; +}