summaryrefslogtreecommitdiff
path: root/bin/guiscripts/mvid
blob: a31a2218a7559611437a01785a708ba37e5ea751 (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%"
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)"