2021-10-16 08:46:54 +00:00
|
|
|
#!/bin/sh -e
|
2021-10-17 10:23:29 +00:00
|
|
|
# launch my focus playlist or find a matching playlist or song files
|
|
|
|
# depends: mp mpc
|
|
|
|
# env: MUSIC
|
2022-08-04 21:53:53 +00:00
|
|
|
# args: either a playlist file name, or a list of terms which all have to match
|
2022-12-22 14:44:02 +00:00
|
|
|
# TODO fails on "Alchemy"
|
2023-07-27 15:16:41 +00:00
|
|
|
# TODO implement tags
|
2022-08-04 21:53:53 +00:00
|
|
|
PLAYLISTS="${PLAYLISTS:-$MUSIC/Playlists}"
|
2021-10-22 15:14:41 +00:00
|
|
|
mpc -q clear
|
2021-10-16 08:46:54 +00:00
|
|
|
if test -z "$1"
|
2021-10-17 10:23:29 +00:00
|
|
|
then mp -q "$PLAYLISTS/focus.m3u"
|
2021-10-16 08:46:54 +00:00
|
|
|
else
|
2022-01-08 21:53:49 +00:00
|
|
|
(find -L $PLAYLISTS -iname "focus-$1.m3u" -print0 | grep --null-data . ||
|
|
|
|
find -L $PLAYLISTS -iname "$1.m3u*" -print0 | grep --null-data . ||
|
2022-05-03 09:29:48 +00:00
|
|
|
find -L $MUSIC $(echo "$@" | sed 's/\w\+/-iname *\0* /g') -prune -exec find {} -size +1M -type f -not -iregex ".*.\(jpe?g\|png\)" -print0 \; ) |
|
2022-01-08 21:53:49 +00:00
|
|
|
xargs -0 mp -q
|
|
|
|
fi
|
|
|
|
if test $(mpc playlist | wc -l) -gt 1; then
|
|
|
|
mpc -q shuffle
|
|
|
|
mpc next
|
2021-10-16 08:46:54 +00:00
|
|
|
fi
|