Created
June 5, 2020 07:02
-
-
Save lukec11/b23865b3de10acaeefd68661fe89c726 to your computer and use it in GitHub Desktop.
obs-timer-linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
import time | |
import os | |
setHour = int(input('Hour: ')) | |
setMin = int(input('Minute: ')) | |
setTime = datetime( | |
year = datetime.today().year, | |
month = datetime.today().month, | |
day = datetime.now().day, | |
hour = setHour, | |
minute = setMin | |
) | |
while True: #constantly looping timer because life is stupid | |
currentTime = datetime.now() | |
diff = setTime - currentTime # time difference | |
timeArr = str(diff).split(':') | |
ftime = f'{timeArr[1]}:{timeArr[2].split(".")[0]}' | |
print(ftime) | |
with open ('timer.txt', 'w') as f: #opens timer file | |
f.seek(0) # goes to beginning of file | |
f.write(ftime) # Writes the current time into the file | |
f.truncate() # Cuts off the file | |
time.sleep(1) #sleeps 1s until next update so we don't need threading | |
if (ftime) == '00:00': #kill the program if the timer reaches 0 | |
exit() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment