Skip to content

Instantly share code, notes, and snippets.

@dgnsrekt
Created May 18, 2019 18:20
Show Gist options
  • Save dgnsrekt/5c88d8747763bab07a1213fbe7da8e21 to your computer and use it in GitHub Desktop.
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.
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