summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mpdf
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-04-19 21:35:09 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-04-19 21:35:09 +0200
commit91f746f6f6ed69dfc2e1a571ac3439ed09ee64d6 (patch)
tree0af3bdfcafc99f1819df2ba88c9539c238fa2752 /bin/menuscripts/mpdf
parentb1ef4dd05c424b196135ec767b4ac987112edae6 (diff)
moved dmpdf to menuscripts
Diffstat (limited to 'bin/menuscripts/mpdf')
-rwxr-xr-xbin/menuscripts/mpdf25
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/menuscripts/mpdf b/bin/menuscripts/mpdf
new file mode 100755
index 0000000..d26c841
--- /dev/null
+++ b/bin/menuscripts/mpdf
@@ -0,0 +1,25 @@
+#!/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/aluc|\~| ; s|\([^/]\)[^/]*/|\1/|g' "$tmp" |
+ awk '{printf "%s %s\n", NR ":", $0}' |
+ $menucmd |
+ grep -oE "^[0-9]+:" |
+ cut -f1 -d:)"
+if [ -z "$choice" ]; then
+ exit
+fi
+file="$(sed -n "${choice}p" "$tmp")"
+zathura "$file" &