writing: Consolidate into module

For now, contains bibtex and zathura options, though it will undoubtedly
increase as I add more writing utilities (such as jrnl) into the repo.
This commit is contained in:
Marty Oehme 2023-01-07 15:56:03 +01:00
parent e9659a2829
commit 04c02fde72
Signed by: Marty
GPG key ID: 73BA40D5AFAF49C9
6 changed files with 6 additions and 1 deletions

View file

@ -1,29 +0,0 @@
#!/usr/bin/env sh
exist rofi normal
_rofi() {
rofi -dmenu -no-auto-select -i -theme themes/dropdown -p "papers" -l 25 -yoffset 20 -columns 1 -u "$urgent"
}
# call for whatever file is passed in
results="$(bib-due "$@")"
# 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
choice=$(echo "$results" | _rofi)
[ -z "$choice" ] && exit 0
key=$(echo "$choice" | sed -E 's/.*\((\w+)\)$/\1/')
# get library pdf folder (only searches for default ./pdf path)
library="$(dirname "$(realpath "$BIBFILE")")/pdf"
# find and open the key-associated pdf file
${FILEREADER:-xdg-open} "$(find "$library" -type f -name "$key *.pdf")"