Skip to content

Instantly share code, notes, and snippets.

@dyeo
Created October 24, 2021 22:45
Show Gist options
  • Save dyeo/98d47ca9e43a2605d720129bed1137a2 to your computer and use it in GitHub Desktop.
Save dyeo/98d47ca9e43a2605d720129bed1137a2 to your computer and use it in GitHub Desktop.
nosel
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xfixes.h>
int main() {
Display *dpy;
Window root;
int ev_base, err_base;
XEvent ev;
if (!(dpy=XOpenDisplay(0x0)))
return 1;
root = DefaultRootWindow(dpy);
XFixesQueryExtension(dpy, &ev_base, &err_base);
XFixesSelectSelectionInput(dpy, root, XA_PRIMARY, XFixesSetSelectionOwnerNotifyMask);
int ignore = 0;
while (!XNextEvent(dpy, &ev)) {
if (ev.type == ev_base + XFixesSelectionNotify) {
if (ignore) {
ignore = 0;
} else {
ignore = 1;
XSetSelectionOwner(dpy, XA_PRIMARY, None, CurrentTime);
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment