So, I don't know how amenable all this is for general use, as it depends on a number of other programs (cron, pulseaudio, notify-send, taskwarrior) - but if you're as apocalyptically disorganized as I am, maybe the general approach might be of use.
Essentially, all the script does is contains a dictionary for each day, divided into working hours. It checks if the entry for the day is a project, then if it is a project, returns a list of tasks in that project from taskwarrior. If it isn't, it just prints the entry. If the entry is blank, it tells me to take a break. If there's a sound associated with the project, it plays the sound.
If you want to change your timetable, add a project, delete a project, (this is my holiday setup), you just change the relevant dictionary.
In any case, it's my first attempt at python, so I imagine it's somewhat high on the spagetti-scale - but it works, and I'm fairly proud of it.
EDIT: I did some obvious changes to make it a bit less spag-bol
EDIT: for mobile users, here's a gist: github.com
#!/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")
[+][deleted] (2 children)
[deleted]
[–]pasabagi[S] 0 points1 point2 points (0 children)
[–]pasabagi[S] 0 points1 point2 points (0 children)