summary refs log tree commit diff
path: root/clipnotify.c
blob: e0440b380dd94296ece30aed9c73d951ad6300c6 (plain) (blame)
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
33
34
35
36
37
38
39
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
#include <stdio.h>
#include <stdlib.h>

#ifdef __OpenBSD__
#define MAYBE_PLEDGE(p, ep) pledge(p, ep)
#else
#define MAYBE_PLEDGE(p, ep) 0
#endif /* __OpenBSD__ */

int main(void) {
    Display *disp;
    Window root;
    Atom clip;
    XEvent evt;

    if (MAYBE_PLEDGE("stdio rpath", NULL) < 0) {
        perror("pledge");
        exit(2);
    }

    disp = XOpenDisplay(NULL);
    if (!disp) {
        fprintf(stderr, "Can't open X display\n");
        exit(1);
    }

    root = DefaultRootWindow(disp);

    clip = XInternAtom(disp, "CLIPBOARD", False);

    XFixesSelectSelectionInput(disp, root, XA_PRIMARY, XFixesSetSelectionOwnerNotifyMask);
    XFixesSelectSelectionInput(disp, root, clip, XFixesSetSelectionOwnerNotifyMask);

    XNextEvent(disp, &evt);
    XCloseDisplay(disp);
}