Created
May 18, 2019 18:20
-
-
Save dgnsrekt/5c88d8747763bab07a1213fbe7da8e21 to your computer and use it in GitHub Desktop.
For people with tradingview alarms that go off in the middle of the night.
This file contains hidden or 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
import alsaaudio | |
import schedule | |
import time | |
MUTE_TIME = 19 | |
UNMUTED = [False, False] | |
MUTED = [True, True] | |
def job(): | |
current_hour = time.localtime().tm_hour | |
print("current hour:", current_hour) | |
if current_hour > MUTE_TIME: | |
mixer = alsaaudio.Mixer() | |
volume = mixer.getvolume() | |
if mixer.getmute() == UNMUTED: | |
print("muting sound.") | |
mixer.setmute(True) | |
schedule.every(1).minutes.do(job) | |
while True: | |
schedule.run_pending() | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment