annoying/main.c

40 lines
906 B
C
Raw Normal View History

2019-06-02 15:26:49 +00:00
#include <stdlib.h>
2019-06-02 14:46:54 +00:00
#include <X11/Xlib.h>
2019-06-02 15:26:49 +00:00
#include <time.h>
#include <stdbool.h>
2019-06-02 15:35:31 +00:00
#include <zconf.h>
2019-06-02 15:26:49 +00:00
2019-06-02 15:41:43 +00:00
int getRandom(int lower, int upper) {
unsigned int seed = (unsigned int) time(NULL);
srand(seed);
return rand() % (upper - lower + 1) + lower;
}
void moveCursor() {
2019-06-02 15:26:49 +00:00
Display *dpy;
Window root_window;
dpy = XOpenDisplay(0);
2019-06-02 15:41:43 +00:00
Screen *screen = XScreenOfDisplay(dpy, 0);
2019-06-02 15:26:49 +00:00
root_window = XRootWindow(dpy, 0);
2019-06-02 15:46:09 +00:00
unsigned int width = (unsigned int) XWidthOfScreen(screen);
unsigned int height = (unsigned int) XHeightOfScreen(screen);
2019-06-02 15:26:49 +00:00
2019-06-02 15:41:43 +00:00
int destX = getRandom(0, width);
int destY = getRandom(0, height);
XWarpPointer(dpy, None, root_window, 0, 0, width, height, destX, destY);
XFlush(dpy);
2019-06-02 15:26:49 +00:00
}
2019-06-02 14:46:54 +00:00
2019-06-02 14:32:57 +00:00
int main() {
2019-06-02 15:35:31 +00:00
while(true) {
2019-06-02 15:46:09 +00:00
sleep(getRandom(60, 600));
2019-06-02 15:35:31 +00:00
if (getRandom(0, 100) > 50) {
continue;
}
2019-06-02 15:26:49 +00:00
2019-06-02 15:41:43 +00:00
moveCursor();
2019-06-02 15:26:49 +00:00
}
2019-06-02 14:32:57 +00:00
}