Created
March 1, 2017 14:21
-
-
Save r3dact3d/519927221c0eaf266122ddf8404e1862 to your computer and use it in GitHub Desktop.
Simple Python Alarm Clock
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
#!/usr/bin/env python | |
# coded by Brady [r3dact3d] | |
# set days of week to run alarm in days list | |
# set song you want to wakeup to in song | |
# set hour and minute in h, m | |
# make sure mpg123 is installed on your linux | |
import time, datetime, os | |
def alarm(h, m, song): | |
player = 'mpg123' | |
while(True): | |
day = datetime.datetime.today().weekday() | |
days = [0, 1, 2, 3, 4, 5] | |
if(day in days): | |
dt = list(time.localtime(time.time())) | |
hour = str(dt[3]) | |
minute = str(dt[4]) | |
if hour == h and minute == m: | |
command = '%s %s' % (player, song) | |
process = os.popen(command) | |
time.sleep(0.1) | |
song = '/home/itsbt/wakeup.mp3' | |
h = '8' | |
m = '17' | |
alarm(h, m, song) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment