From 22f001c91a158c1bc576a74ecae5a33402f83ab8 Mon Sep 17 00:00:00 2001 From: Sam Nystrom Date: Mon, 19 Jun 2023 23:56:12 -0400 Subject: bin/shuffle: add option for mpv extra options --- bin/shuffle | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/shuffle b/bin/shuffle index c611f32..d8dd878 100755 --- a/bin/shuffle +++ b/bin/shuffle @@ -4,8 +4,39 @@ prev2=-1 prev1=$prev2 index=$prev1 -while :; do - files=$(find "${1:-.}" -type f) +path="." +mpv_opts="--no-video" + +while getopts hm:p: opt 2>/dev/null; do + case "$opt" in + m) + mpv_opts="$mpv_opts $OPTARG" + ;; + p) + path="$OPTARG" + ;; + h) + echo "\ +Usage: $0 [-h] [-m ] [-p ] + +Play audio files in a directory in (mostly) random order. + +Options: + -m Pass as extra options to mpv + -p Play files in instead of the current directory + -h Print this help text +" >&2 + exit 0 + ;; + ?) + echo "Usage: $0 [-h] [-m ] [-p ]" >&2 + exit 1 + ;; + esac +done + +while true; do + files=$(find "$path" -type f) n=$(echo "$files" | wc -l) while [ $index -eq $prev2 ] || [ $index -eq $prev1 ]; do @@ -18,7 +49,7 @@ while :; do while read -r file; do if [ $i -eq $index ]; then echo "Playing $file" - mpv --no-video "$file" || : + mpv $mpv_opts "$file" || true break fi i=$((i + 1)) -- cgit v1.2.3