Compare commits

..

No commits in common. "master" and "v01" have entirely different histories.
master ... v01

1 changed files with 4 additions and 33 deletions

37
main.c
View File

@ -3,15 +3,11 @@
#include <time.h>
#include <stdbool.h>
#include <zconf.h>
#include <string.h>
#include <stdio.h>
bool debugEnabled = false;
unsigned int getRandom(int lower, int upper) {
int getRandom(int lower, int upper) {
unsigned int seed = (unsigned int) time(NULL);
srand(seed);
return (unsigned int) (rand() % (upper - lower + 1) + lower);
return rand() % (upper - lower + 1) + lower;
}
void moveCursor() {
@ -29,40 +25,15 @@ void moveCursor() {
XWarpPointer(dpy, None, root_window, 0, 0, width, height, destX, destY);
XFlush(dpy);
if (debugEnabled) {
printf("Moved cursor to x: %d y: %d.\n", destX, destY);
}
}
int main(int argc, char **argv) {
int minSleep = 60;
int maxSleep = 600;
if(argc > 1) {
for (int i = 1; i <= (argc - 1); ++i) {
if (strcmp(argv[i], "--debug") == 0) {
debugEnabled = true;
minSleep = 1;
maxSleep = 10;
}
}
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
int main() {
while(true) {
unsigned int sleepTime = getRandom(minSleep, maxSleep);
if (debugEnabled) {
printf("Sleeping for %d seconds.\n", sleepTime);
}
sleep(sleepTime);
sleep(getRandom(60, 600));
if (getRandom(0, 100) > 50) {
continue;
}
moveCursor();
}
#pragma clang diagnostic pop
}