In this post I will explain my university workflow/setup, which I adopted around the third quartile of 2020 and has been improved ever since. It has mostly been inspired by Gilles Castel’s university setup, with a couple changes/tweaks (which are worth the read!).

Folder structure

The folder structure of my university folder is as follows:

├── bachelor-3
├── master-1
├── master-2
│   └── mod1
│       ├── Cyber Risk Management
│       │   ├── info.yaml
│       │   ├── lectures
│       │   └── papers
│       ├── Economics Of Cybersecurity
│       │   ├── info.yaml
│       │   ├── lectures
│       │   └── papers
│       ├── Secure Cloud Computing
│       │   ├── info.yaml
│       │   ├── lectures
│       │   └── papers
│       └── Secure Data Management
│           ├── info.yaml
│           ├── lectures
│           └── papers
├── module-current -> /home/pim/university/master-2/mod1
└── course-current -> /home/pim/university/module-current/Secure Cloud Computing

My university program is organized in four quartiles, or modules per academic year. Each have their own courses, as can be seen above. Every course contains an info.yaml, which has the following content:

name: 'Secure Cloud Computing (SCC)'
url: 'https://university.com/courses/8981'
short: 'SCC'

More on this YAML file later.

Switching courses

If I press Alt + s, the course_switch script (can be found in the appendices) will be executed, that gives me the following rofi prompt:

course_switch

It finds all the folders in my module-current folder (which represent courses) and displays them. The course I select is what the symlink course-current will be updated with.

Opening PDF files quickly

All my courses folders have a papers and lectures folder. Another script I have is select_pdf (see appendices). You give it a location, prompt name, and an optional recursive flag. It finds all the PDF files in a directory, and shows a rofi prompt with the results. The selected result will be opened in $READER:

select_lecture

As you can see, the second argument of select_pdf (“lecture”) will be appended to “Select a” in the rofi prompt.

If you add a recursive flag, like -R, it will recursively look in the directory for PDF files, like I do for my papers folder (command can be seen in the appendices):

select_paper

Other useful keybindings/things

Here I list some keybindings, that can all be found in the appendix.

  • Alt + f opens the course web URL (parsed from the YAML) in my browser. To parse YAML, yq is needed.
  • Alt + v opens a file called notes.md (located in the root of course-current) in my text editor.
  • Alt + d opens the course-current folder in my terminal.

Finally, I am using polybar as statusbar for my WM (i3). The course short code (parsed from the YAML) will be displayed in my statusbar as well. Polybar config module can be found in the appendices.

Appendices:

course_switch

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#!/bin/bash
cd "$HOME/university/module-current/" || exit
COURSES=$(find . -maxdepth 1 -not -path '*/\.*' -type d | cut -c3- | tail -n +2)
LINES=$(echo "$COURSES" | wc -l)
cd - || exit


chosen=$(echo -e "$COURSES" | rofi -dmenu -l "$LINES" -p "Select a course" -i)

if [ -n "$chosen" ] && [ -d ~/university/module-current/"$chosen" ]; then
    ln -sfT ~/university/module-current/"$chosen" ~/university/course-current
fi

select_pdf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh -e

[ -z "$1" ] && echo "Please provide a directory as the first argument" && exit 1
[ -z "$2" ] && echo "Please provide a prompt as the second argument" && exit 1

DIR="$1"
PROMPT="$2"
RECURSIVE="$3"

cd "$DIR" || mkdir -p "$DIR"

[ -z "$RECURSIVE" ] && RESULTS=$(find -L . -type f -iregex "\.\/[^\/]*\.pdf" | sort)
[ -z "$RECURSIVE" ] || RESULTS=$(find -L . -type f -iregex "\.\/.*\.pdf" | sort)

LINES=$(echo "$RESULTS" | wc -l)

BOOK=$(echo "$RESULTS" | cut -c 3- | rofi -dmenu -l "$LINES" -p "Select a $PROMPT" -i)

if [ "$BOOK" != "" ]
then
    setsid -f "$READER" "$BOOK"
fi

i3 keybindings

bindsym mod1 + v exec $TERMINAL -e $EDITOR ~/university/course-current/notes.md
bindsym mod1 + f exec $BROWSER $(yq -r .url ~/university/course-current/info.yaml)
bindsym mod1 + d exec $TERMINAL --working-directory=/home/pim/university/course-current
bindsym mod1 + u exec $TERMINAL --working-directory=/home/pim/university
bindsym mod1 + s exec course_switch
bindsym mod1 + b exec select_pdf "/home/pim/university/course-current" "book"
bindsym mod1 + l exec select_pdf "/home/pim/university/course-current/lectures" "lecture" "-R"
bindsym mod1 + p exec select_pdf "/home/pim/university/course-current/papers" "paper" "-R"

Polybar config file

[module/course]
type = custom/script

click-left = $TERMINAL --working-directory ~/university/course-current
click-right = $BROWSER $(yq -r .url ~/university/course-current/info.yaml)
exec = yq -cM .short "$HOME/university/course-current/info.yaml" | sed "s/\"//g"
format = <prefix> <label>