diff options
Diffstat (limited to 'extras')
| -rwxr-xr-x | extras/HOME/.local/bin/library-view.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/extras/HOME/.local/bin/library-view.sh b/extras/HOME/.local/bin/library-view.sh new file mode 100755 index 0000000..29925a8 --- /dev/null +++ b/extras/HOME/.local/bin/library-view.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +MENU=(rofi -i -dmenu -sort -theme-str '* {theme-color: #ff88ff;}' -p "Library") + +if (which zathura) ; then + pdfviewer=zathura +elif (which evince) ; then + pdfviewer=evince +else + pdfviewer='xdg-open' +fi + + +cd ~/Library + +files=(*.pdf) + +file_with_title="$(for file in "${files[@]}" ; do + echo "$file| $(echo "$file" | sed 's#\(^\|_\|\s\)\([a-z]\)#\1\U\2#g' | tr '_' ' ' | sed 's/.[^.]*$//')" +done)" + +selected=$(echo "$file_with_title" | (while read file ; do + echo "${file//*|}" +done) | "${MENU[@]}") + +if [ ! -z "${selected}" ] ; then + $pdfviewer "$(echo "$file_with_title" | grep "$selected" | sed 's/|.*//')" +fi |