Skip to content

Instantly share code, notes, and snippets.

@guihkx
Created May 26, 2021 05:45
Show Gist options
  • Save guihkx/e695a034f1e20eb4eea7e4cf5c47a6e0 to your computer and use it in GitHub Desktop.
Save guihkx/e695a034f1e20eb4eea7e4cf5c47a6e0 to your computer and use it in GitHub Desktop.
/*
* 1. Compile it: gcc spam.c -lX11 -lXrandr -Wall -Wextra -Werror -std=c89 -O3 -pedantic-errors -o spam
* 2. Start monitoring the journal: journalctl -f
* 3. Run the program in a loop: while true; do ./spam && sleep 1; done
* 4. Observe the journal being spammed (GNOME-only)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
int main(void)
{
char *dpy;
Display *xdpy;
Window root;
XRRScreenResources *srs;
dpy = getenv("DISPLAY");
xdpy = XOpenDisplay(dpy);
if (!xdpy) {
fprintf(stderr, "Unable to open X display '%s': %s\n", dpy, strerror(errno));
return 1;
}
root = DefaultRootWindow(xdpy);
srs = XRRGetScreenResources(xdpy, root); /* <-- journal spam happens here */
XRRFreeScreenResources(srs);
XCloseDisplay(xdpy);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment