summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mvid
blob: 8d14c4bc89da58c23daad8d34a0c36c84f1870f3 (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
26
#!/usr/bin/env sh

dirs="${1:-$HOME/vids $HOME/dl}"
find -L $dirs 2> /dev/null |
	grep ".\+\.\(webm\|mp4\|mpeg\|mkv\)$" |
	sort > /tmp/dmvids
cat /tmp/dmvids

if [ "$MENUCMD" = "tofi" ]
then
	menucmd="tofi --width 30% --height 30% --matching-algorithm normal"
elif [ "$MENUCMD" = "dmenu" ]
then
	menucmd="dmenu -l 10 -g 1 -x -i" 
else
	menucmd="fzf"
fi

choice="$(sed 's|^/home/aluc|\~| ; s|\([^/]\)[^/]*/|\1/|g' /tmp/dmvids | 
	awk '{printf "%s %s\n", NR ":", $0}' | 
	$menucmd | 
	cut -f 1 -d ':')"
test -z "$choice" &&
	exit 1

mpv "$(sed -n "${choice}p" /tmp/dmvids)"