commit 7d36e6b416d0e51618a4544d8d67321457a60da6
parent 31c122b64d91cba0bd12237952e1e88d38e775d5
Author: lostd <lostd@2f30.org>
Date: Sat, 14 May 2016 19:13:28 +0100
Set X root window name
Diffstat:
M | spoon.c | | | 27 | ++++++++++++++++++++++++--- |
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/spoon.c b/spoon.c
@@ -1,6 +1,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -141,11 +142,31 @@ entcat(char *line, size_t len)
}
}
+void
+xsetroot(void)
+{
+ char line[BUFSIZ];
+ Display *dpy;
+ int screen;
+ Window root;
+
+ dpy = XOpenDisplay(NULL);
+ if (dpy == NULL)
+ errx(1, "cannot open display");
+ screen = DefaultScreen(dpy);
+ root = RootWindow(dpy, screen);
+
+ for (;;) {
+ entcat(line, sizeof(line));
+ XStoreName(dpy, root, line);
+ XFlush(dpy);
+ sleep(1);
+ }
+}
+
int
main(void)
{
- char line[BUFSIZ];
- entcat(line, sizeof(line));
- puts(line);
+ xsetroot();
return 0;
}