about summary refs log tree commit diff
path: root/clipnotify.c
diff options
context:
space:
mode:
authorChris Down <chris@chrisdown.name>2018-02-05 23:37:53 +0000
committerChris Down <chris@chrisdown.name>2018-02-05 23:37:53 +0000
commit493e4cd1f0cf831540454426d65b0509a8f32d75 (patch)
tree41d0f892338a539c004d3d07e495e43b5d854b5a /clipnotify.c
downloadclipbuzz-493e4cd1f0cf831540454426d65b0509a8f32d75.tar.gz
Add initial version of clipnotify
Diffstat (limited to 'clipnotify.c')
-rw-r--r--clipnotify.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/clipnotify.c b/clipnotify.c
new file mode 100644
index 0000000..8adac43
--- /dev/null
+++ b/clipnotify.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/extensions/Xfixes.h>
+
+int main(void) {
+    Display *disp;
+    Window root;
+    Atom clip;
+    XEvent evt;
+
+    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);
+
+    return 0;
+}