From a41ac9102ae26e46fa802f6be2bb8aba75c301a2 Mon Sep 17 00:00:00 2001 From: Maxim Likhachev Date: Fri, 12 Feb 2021 16:02:33 +0300 Subject: [PATCH] ++rat-race --- README.md | 1 + scripts/rat-race | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 scripts/rat-race diff --git a/README.md b/README.md index 8fd8b3d..bb791f8 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ will create the symbolic link for each script in the \ directory. - [defgroups](scripts/defgroups) adds a user to default system groups. - [passgen](scripts/passgen) creates the strong passwords. +- [rat-race](scripts/rat-race) perpetually and randomly moves the mouse cursor. - [sync-date](scripts/sync-date) sets system time according to Google. - [xsmartlight](scripts/xsmartlight) allows to adjust ASUS smartscreen's brightness. - [use](scripts/use) shows Gentoo USE flag's description. diff --git a/scripts/rat-race b/scripts/rat-race new file mode 100755 index 0000000..913bcd0 --- /dev/null +++ b/scripts/rat-race @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +# +# This simple scenario moves the mouse cursor every N seconds, +# keeping the input devices active and preventing the computer +# from going into sleep/standby mode. +# +# Requirements: +# +# python: +# - pyautogui +# +# MacOS: +# - add iTerm to Settings -> Security & Privacy -> Accessibility. +# + +import pyautogui +import random +import time +import sys + +def timestamp(): + return time.strftime("%Y-%H-%M %T", time.localtime(int(time.time()))) + +t = 1 if len(sys.argv) == 1 else int(sys.argv[1]) + +screenWidth, screenHeight = pyautogui.size() + +print(f"[{timestamp()}] Rat-race scenario is started.") +print(f"[{timestamp()}] The mouse cursor will move every {t} seconds.") +print(f"[{timestamp()}] Current screen resolution is {screenWidth}x{screenHeight}.") + +while True: + x, y = random.randrange(screenWidth), random.randrange(screenHeight) + + print(f"[{timestamp()}] > moving the cursor to point {x : >4},{y}") + + pyautogui.moveTo(x, y) + + time.sleep(t) +