annoying/main.c

40 lines
906 B
C

#include <stdlib.h>
#include <X11/Xlib.h>
#include <time.h>
#include <stdbool.h>
#include <zconf.h>
int getRandom(int lower, int upper) {
unsigned int seed = (unsigned int) time(NULL);
srand(seed);
return rand() % (upper - lower + 1) + lower;
}
void moveCursor() {
Display *dpy;
Window root_window;
dpy = XOpenDisplay(0);
Screen *screen = XScreenOfDisplay(dpy, 0);
root_window = XRootWindow(dpy, 0);
unsigned int width = (unsigned int) XWidthOfScreen(screen);
unsigned int height = (unsigned int) XHeightOfScreen(screen);
int destX = getRandom(0, width);
int destY = getRandom(0, height);
XWarpPointer(dpy, None, root_window, 0, 0, width, height, destX, destY);
XFlush(dpy);
}
int main() {
while(true) {
sleep(getRandom(60, 600));
if (getRandom(0, 100) > 50) {
continue;
}
moveCursor();
}
}