diff options
| -rwxr-xr-x | extras/HOME/.local/bin/library-view.sh | 28 | ||||
| -rw-r--r-- | src/Internal/Keys.hs | 3 |
2 files changed, 31 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 diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs index 3189ddb..936b12a 100644 --- a/src/Internal/Keys.hs +++ b/src/Internal/Keys.hs @@ -244,6 +244,9 @@ keymap = runKeys $ do bind xK_w $ (justMod -|- noMod) $ spawn "networkmanager_dmenu" + bind xK_o $ + (justMod -|- noMod) $ spawn "library-view.sh" + bind xK_v $ do (justMod -|- noMod) $ spawn "set-volume.sh" (shiftMod -|- rawMask shiftMask) $ spawn "set-volume.sh -a" |