summaryrefslogtreecommitdiff
path: root/bin/guiscripts/dmpdf
blob: d26c84108eab6100151c6d88dc403ca077d71e89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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" &