2019-09-15 20:42:11 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
from courses import Courses
|
|
|
|
from rofi import rofi
|
2021-09-16 15:34:26 +02:00
|
|
|
from utils import generate_short_title
|
2022-07-26 20:02:57 +02:00
|
|
|
from config_loader import MAX_LEN
|
2019-09-15 20:42:11 +02:00
|
|
|
|
2021-09-18 13:43:19 +02:00
|
|
|
notes = Courses().current.notes
|
|
|
|
lectures = notes.lectures
|
2019-09-15 20:42:11 +02:00
|
|
|
|
|
|
|
sorted_lectures = sorted(lectures, key=lambda l: -l.number)
|
|
|
|
|
|
|
|
options = [
|
|
|
|
"{number: >2}. <b>{title: <{fill}}</b> <span size='smaller'>{date} ({week})</span>".format(
|
|
|
|
fill=MAX_LEN,
|
|
|
|
number=lecture.number,
|
|
|
|
title=generate_short_title(lecture.title),
|
|
|
|
date=lecture.date.strftime('%a %d %b'),
|
|
|
|
week=lecture.week
|
|
|
|
)
|
|
|
|
for lecture in sorted_lectures
|
|
|
|
]
|
|
|
|
|
|
|
|
key, index, selected = rofi('Select lecture', options, [
|
|
|
|
'-lines', 5,
|
|
|
|
'-markup-rows',
|
|
|
|
'-kb-row-down', 'Down',
|
2021-09-18 13:43:19 +02:00
|
|
|
'-kb-custom-1', 'Alt+n',
|
|
|
|
'-kb-custom-2', 'Alt+m',
|
|
|
|
'-kb-custom-3', 'Alt+s'
|
2019-09-15 20:42:11 +02:00
|
|
|
])
|
|
|
|
|
|
|
|
if key == 0:
|
|
|
|
sorted_lectures[index].edit()
|
|
|
|
elif key == 1:
|
2021-09-18 13:43:19 +02:00
|
|
|
new_lecture = notes.new_lecture()
|
2019-09-15 20:42:11 +02:00
|
|
|
new_lecture.edit()
|
2021-09-18 13:43:19 +02:00
|
|
|
elif key == 2:
|
|
|
|
notes.edit_master()
|
|
|
|
elif key == 3:
|
|
|
|
notes.edit_full()
|