-
Notifications
You must be signed in to change notification settings - Fork 1
/
play
executable file
·44 lines (38 loc) · 1.03 KB
/
play
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
# play: select and play music with mpv
while true; do
case "$1" in
"-h" | "--help")
echo "usage: play [-d|--directory | -s|--shuffle | -t|--time] [name]"
exit 0
;;
"-d" | "--directory")
directory=1
;;
"-s" | "--shuffle")
shuffle=1
;;
"-t" | "--time")
time=1
;;
*)
break
;;
esac
shift
done
if [ "$shuffle" = "1" ] && [ -z "$directory$time$*" ]; then
mpv --shuffle "$HOME/music"
exit $?
fi
type="${directory:+-type d}"
sort="shuf"
if [ "$time" = "1" ]; then
type="${type:--type f}"
sort="sort --reverse"
fi
find "$HOME/music" -mindepth 1 -not -path '*/.*' $type -printf "%T+ %p\n" \
| $sort \
| cut --delimiter ' ' --fields 2- \
| fzf --delimiter / --with-nth 5.. --print0 --select-1 ${*:+--query="$*"} \
| xargs --null --no-run-if-empty mpv ${shuffle:+--shuffle}