add dwm-setstatus.c

This commit is contained in:
stupidcomputer 2024-11-26 15:36:42 -06:00
parent cd6615819e
commit f972a39b88
2 changed files with 34 additions and 1 deletions

View File

@ -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

30
dwm-setstatus.c Normal file
View File

@ -0,0 +1,30 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
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;
}