2020-05-11 14:37:05 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
exist rofi normal
|
|
|
|
|
|
|
|
_rofi() {
|
2020-05-12 19:42:01 +00:00
|
|
|
rofi -dmenu -no-auto-select -i -theme themes/dropdown -p "papers" -l 25 -yoffset 20 -columns 1 -u "$urgent"
|
2020-05-11 14:37:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# call for whatever file is passed in
|
2020-05-12 19:42:01 +00:00
|
|
|
results="$(bib-due "$@")"
|
2020-05-11 14:37:05 +00:00
|
|
|
|
|
|
|
# mark priority 1 items as urgent in rofi
|
|
|
|
urgent="$(
|
|
|
|
# find all lines with priority 1, (marked as `(1):` );
|
|
|
|
# print them on 1 line, -1 since dmenu is 0 indexed
|
|
|
|
echo "$results" | grep -n '(1):' | cut -d: -f1 | awk '{ $0=$0-1; print $0 }' ORS=','
|
|
|
|
)"
|
|
|
|
|
|
|
|
# get user choice, exit if nothing selected
|
2020-05-12 19:42:01 +00:00
|
|
|
choice=$(echo "$results" | _rofi)
|
2020-05-11 14:37:05 +00:00
|
|
|
[ -z "$choice" ] && exit 0
|
|
|
|
|
|
|
|
key=$(echo "$choice" | sed -E 's/.*\((\w+)\)$/\1/')
|
|
|
|
|
|
|
|
# get library pdf folder (only searches for default ./pdf path)
|
2020-05-12 19:42:01 +00:00
|
|
|
library="$(dirname "$(realpath "$BIBFILE")")/pdf"
|
2020-05-11 14:37:05 +00:00
|
|
|
|
|
|
|
# find and open the key-associated pdf file
|
|
|
|
${FILEREADER:-xdg-open} "$(find "$library" -type f -name "$key *.pdf")"
|