summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpdf
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-22 23:08:50 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-22 23:08:50 +0200
commit067b271a243dafcf652fe7cfe85e723d25ff1a64 (patch)
treec546402b2c40ca1e0739d1cc404f1d04d1d45067 /bin/menuscripts/mpdf
parent67a2df82d25f52ea0937f4eed355546deae7b4b5 (diff)
parent9172676556847ff625cbf4b4eff19f441e0b9386 (diff)
Merge branch 'main' of /var/git/dotfiles
Diffstat (limited to 'bin/menuscripts/mpdf')
-rwxr-xr-xbin/menuscripts/mpdf24
1 files changed, 6 insertions, 18 deletions
diff --git a/bin/menuscripts/mpdf b/bin/menuscripts/mpdf
index d67fdae..85debfb 100755
--- a/bin/menuscripts/mpdf
+++ b/bin/menuscripts/mpdf
@@ -1,22 +1,10 @@
#!/bin/sh
-if [ "$MENUCMD" = "tofi" ]
-then
- menucmd="tofi --width 30% --height 30% --matching-algorithm normal --prompt-text pdf:"
-elif [ "$MENUCMD" = "dmenu" ]
-then
- menucmd="dmenu -l 10 -g 1 -x -i -p pdf:"
-else
- menucmd="fzf"
-fi
-
-tmp="/tmp/dmpdf"
-find ${1:-$HOME/docs $HOME/dl} 2> /dev/null | grep -E ".+\.pdf" | sort > "$tmp"
-choice="$(sed "s|^$HOME|\~| ; s|\([^/]\)[^/]*/|\1/|g" "$tmp" |
- awk '{printf "%s %s\n", NR ":", $0}' |
- $menucmd |
- grep -o "^[0-9]\+:" |
- cut -f 1 -d :)"
-test -z "$choice" && exit 1
+tmp="/tmp/mpdf"
+choice="$(find ${1:-$HOME/docs $HOME/dl} -iname "*.pdf" 2> /dev/null | sort |
+ tee "$tmp" |
+ sed "s|^$HOME|\~| ; s|\([^/]\)[^/]*/|\1/|g" |
+ commander -x -n)"
file="$(sed -n "${choice}p" "$tmp")"
+[ -r "$file" ] || exit 1
zathura "$file" &