-
Notifications
You must be signed in to change notification settings - Fork 0
/
stay_up.py
39 lines (32 loc) · 1003 Bytes
/
stay_up.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
import time
import pyautogui
from screeninfo import get_monitors
def run_loop():
n = 2
monitors = get_monitors()
chosen_monitor = [m for m in monitors if m.name.endswith(f'DISPLAY{n}')][0]
x = chosen_monitor.x
y = chosen_monitor.y
interval = 60 * 4
while not pyautogui.position() == (0, 0):
pyautogui.moveTo(x + 100, y + 1000, duration=3)
pyautogui.moveTo(x + 1, y + 100, duration=3)
pyautogui.click()
for i in range(interval):
sys.stdout.write(f'\rNext iteration in {interval - i} seconds...')
sys.stdout.flush()
time.sleep(1)
def wake_up():
while True:
pos_before = pyautogui.position()
time.sleep(60 * 4)
pos_after = pyautogui.position()
if pos_before == pos_after:
pyautogui.press('volumedown')
time.sleep(1)
pyautogui.press('volumeup')
if __name__ == '__main__':
wake_up()
# run_loop()
print('Done')