-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathawake.py
33 lines (27 loc) · 1.14 KB
/
awake.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
'''
This script is meant to keep a user's system awake (prevent it from going to sleep, useful for keeping workplace's skype status availaibility lol)
by constantly providing automatic key input from the "DOWN" key of the user's keyboard.
'''
import time
import keyboard # We will need to install this lib via pip first. Use command "pip3 install keyboard"
print(' ')
print('--------------------------------------------------')
print('This script will keep your UNIX/Linux system awake')
print('--------------------------------------------------')
print(' ')
duration = input(
'How long do you need the screen to remain awake? (in minutes) : ')
print(' ')
print('Note : Please press ctrl+c to stop execution manually.')
print(' ')
print('Now Running...')
time_end = time.time() + 60 * int(duration) # This line of code allows the input of time duration in minutes.
try:
while time.time() < time_end:
keyboard.KEY_DOWN
except KeyboardInterrupt: # This will keep the unwanted error hidden.
print(' ')
print('Stopped by user! Exiting...')
print(' ')
print('Execution finished!')
print(' ')