Skip to content

Commit

Permalink
Updated to allow for duration
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerrington committed Mar 24, 2021
1 parent 9e2ada0 commit 0e9e577
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Binary file modified requirements.txt
Binary file not shown.
10 changes: 9 additions & 1 deletion wakey.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import keyboard, time, sys
import os, logging
import ctypes
from datetime import datetime

def main(duration, frequency, verbose, log):

starttime = time.perf_counter()

if log:
# Setup logging
file, ext = os.path.splitext(__file__)
Expand All @@ -28,7 +31,7 @@ def main(duration, frequency, verbose, log):
delay = frequency * 60
thumb = "\U0001F44D"
computer = "\U0001F5A5\U0000FE0F"
print(f"Keeping {computer} awake {thumb}")
print(f"Keeping {computer} awake {thumb}")
if verbose:
print(f'Pressing {keypress} every {delay} seconds')

Expand All @@ -46,6 +49,11 @@ def main(duration, frequency, verbose, log):
keyboard.press_and_release(keypress)

time.sleep(delay) # Sleep for the amount of seconds generated
if duration:
scriptduration = time.perf_counter() - starttime
if scriptduration > duration:
print("Time duration reached. Ending Wakey.")
sys.exit()
except KeyboardInterrupt:
# quit
sys.exit()
Expand Down

0 comments on commit 0e9e577

Please sign in to comment.