how to turn on and off DND?
import time
from datetime import datetime
from plyer import notification
print("_Main_menu_")
print("1. set alarm")
print("2. set timer") #Haven't added yet plz ignore
while True:
MenuChoice = input("select an option: ")
try:
MenuChoice = int(MenuChoice)
except ValueError:
print("Invalid Option")
else:
MenuChoice = int(MenuChoice)
if MenuChoice == 1 or MenuChoice == 2:
break
else: print("Invalid Option")
Time = datetime.now().time()
Time = str(Time)
print(Time[:-10])
if MenuChoice == 1:
while True:
Alarm = input("Set Time(HH:MM): ")
try:
Hour, Min = Alarm.split(":", 1)
Min = int(Min)
Hour = int(Hour)
Valid = False
Valid1 = False
if Min > 59:
print("Min can't be greater than 59")
elif Min < 0:
print("Min can't be less than 0")
else: Valid = True
if Hour > 23:
print("Hour can't be greater than 23")
elif Hour < 0:
print("Hour can't be less than 0")
else: Valid1 = True
if Valid == True and Valid1 == True:
print("Lock in until",Alarm)
#turn on DND
while True:
TimeNow = datetime.now().time() #Loops until Alarm = TimeNow
TimeNow = str(TimeNow)[:-10]
time.sleep(.5)
if TimeNow == Alarm:
break
#Turn off DND
notification.notify(
title="Time to take a break",
message=f"it's {Alarm}, time to take a break",
timeout=5
)
break
except ValueError:
print("Invalid")
Above is my focus alarm I'm working on, could someone help with adding DND?