Created
January 1, 2018 16:09
-
-
Save nowakf/02ca2563d4e6d27592cfe1fbab3d75fe to your computer and use it in GitHub Desktop.
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/python | |
import datetime | |
import os | |
import tasklib | |
os.environ['XDG_RUNTIME_DIR'] = '/run/user/1000' | |
now = datetime.datetime.now() | |
def day(day, time): | |
try: | |
alert(day[time], time) | |
except KeyError: | |
print("only work hous are defined- change the crontab") | |
monday = { | |
9: "creative", | |
10: "", | |
11: "", | |
12: "", | |
13: "german", | |
14: "Eat lunch", | |
15: "physical", | |
16: "", | |
17: "writing", | |
18: "start cooking supper" | |
} | |
tuesday = { | |
9: "creative", | |
10: "", | |
11: "", | |
12: "", | |
13: "german", | |
14: "Eat lunch", | |
15: "physical", | |
16: "", | |
17: "shopping", | |
18: "start cooking supper" | |
} | |
wednesday = { | |
9: "creative", | |
10: "", | |
11: "", | |
12: "", | |
13: "german", | |
14: "Eat lunch", | |
15: "physical", | |
16: "", | |
17: "writing", | |
18: "start cooking supper" | |
} | |
thursday = { | |
9: "creative", | |
10: "", | |
11: "", | |
12: "", | |
13: "german", | |
14: "Eat lunch", | |
15: "physical", | |
16: "", | |
17: "writing", | |
18: "" | |
} | |
friday = { | |
9: "creative", | |
10: "", | |
11: "", | |
12: "", | |
13: "german", | |
14: "Eat lunch", | |
15: "physical", | |
16: "", | |
17: "writing", | |
18: "" | |
} | |
saturday = { | |
9: "", | |
10: "", | |
11: "", | |
12: "Do household stuff", | |
13: "", | |
14: "Eat lunch", | |
15: "", | |
16: "shopping", | |
17: "writing", | |
18: "" | |
} | |
sunday = { | |
9: "", | |
10: "", | |
11: "", | |
12: "", | |
13: "", | |
14: "Eat lunch", | |
15: "", | |
16: "", | |
17: "writing", | |
18: "start cooking supper", | |
} | |
def playsound(filename): | |
path = "~/Music/hoursounds/" | |
extension = ".ogg" | |
if os.path.isfile('paplay '+path+filename+extension): | |
os.system(path+filename+extension) | |
else: | |
os.system('paplay '+path+"default"+extension) | |
projects = { | |
"writing", | |
"german", | |
"creative", | |
"household", | |
"shopping", | |
"physical" | |
} | |
def alert(scheduleEntry, time): | |
if scheduleEntry == "": | |
os.system('notify-send '+"'take a long break!'") | |
elif scheduleEntry in projects: | |
os.system('notify-send "'+scheduleEntry+'"') | |
tw = tasklib.TaskWarrior(data_location='~/.task', create=False) | |
tasks = tw.tasks.filter(status='pending', project=scheduleEntry) | |
if len(tasks) > 0: | |
for task in tasks: | |
os.system('notify-send '+str(task)) | |
else: | |
os.system('notify-send '+"'no "+scheduleEntry+" tasks left'") | |
else: | |
os.system('notify-send "'+scheduleEntry+'"') | |
playsound(scheduleEntry) | |
days = { | |
0: monday, | |
1: tuesday, | |
2: wednesday, | |
3: thursday, | |
4: friday, | |
5: saturday, | |
6: sunday | |
} | |
try: | |
day(days[now.today().weekday()], now.hour) | |
except KeyError: | |
print("very strange - this isn't a day") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is this?
It's a script designed to run every work-hour, which will:
Why doesn't it work?
This script depends on:
I was really presenting this more as an idea for an approach to solving a problem, rather than as a drop-in application. I'm not a programmer - and, while I think this is useful (since I don't know of any very simple timetable programs) - I think anybody even barely competent would no doubt be able to improve upon it.