summaryrefslogtreecommitdiff
path: root/bin/dmscripts/dmpdf
blob: 6137e1a4eafc0bfbd828d0357d4fce85cc3fa394 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
directory="${1:-$PWD}"
choice="$(\
    find "${directory}" \
        -type f \
        -iname "*.pdf" \
        -printf "%p\n" \
        | awk -F '/' '{print $(NF - 1) "/" $NF}' \
    | sort \
    | uniq \
    | dmenu -i -x -p "pdf:" -l 10 -g 2 \
    | awk -F '/' '{print $2}' \
)"

# find matching file
file="$(\
  find "$directory" -name "*$choice*" \
)"

[[ -f "$file" ]] || exit 1
evince "$file" &