blob: 0abdcd04b8a129f4dc2e7afc925af8154e70a0b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#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);
fprintf(stderr, "Input: %s", input);
fprintf(stderr, "\nbytes read: %ld\n", bytes_read);
}
free(input);
return 0;
}
|