~kris/dots

srice

ref: ff7367cb2ef828502c3f7fde003f45d5daa33206 srice/.local/bin/rofi-lectures-view.py -rw-r--r-- 1.4 KiB
ff7367cb — Kris Yotam add ram memory visualization script 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
"""
===============================================================
 Script: rofi-lectures-view.py
 Author: Kris Yotam (aka. khr1st)
 Date:   2025-09-29
 License: MIT License
 Description:
   Rofi interface to update which lectures are included in
   master.tex for the current course. Lets user quickly select
   between preset lecture ranges and recompiles the notes.

 Inspiration:
   Adapted and extended from Gilles Castel's lecture note workflow.
===============================================================
"""

from courses import Courses
from rofi import rofi


def select_view():
    """
    Show lecture range options in rofi, return command string.
    """
    commands = ["last", "prev-last", "all", "prev"]
    options = [
        "Current lecture",
        "Last two lectures",
        "All lectures",
        "Previous lectures",
    ]

    _, index, selected = rofi(
        "Select view",
        options,
        ["-lines", "4", "-auto-select"],
    )

    if index >= 0:
        return commands[index]
    return selected


def main():
    lectures = Courses().current.lectures
    command = select_view()
    lecture_range = lectures.parse_range_string(command)
    lectures.update_lectures_in_master(lecture_range)
    lectures.compile_master()
    print(f"[ok] Updated master.tex with {command} lectures")


if __name__ == "__main__":
    main()