summaryrefslogtreecommitdiff
path: root/bin/shuffle
diff options
context:
space:
mode:
authorSam Nystrom <sam@samnystrom.dev>2023-06-19 23:56:12 -0400
committerSam Nystrom <sam@samnystrom.dev>2023-06-19 23:56:12 -0400
commit22f001c91a158c1bc576a74ecae5a33402f83ab8 (patch)
tree42e237ac1c0779dcc5df2d3951d65ddb3693d290 /bin/shuffle
parentb0f178c8577d6798c27ae454d8155a5ead1c5fa1 (diff)
bin/shuffle: add option for mpv extra options
Diffstat (limited to 'bin/shuffle')
-rwxr-xr-xbin/shuffle37
1 files changed, 34 insertions, 3 deletions
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 <opts>] [-p <path>]
+
+Play audio files in a directory in (mostly) random order.
+
+Options:
+ -m <opts> Pass <opts> as extra options to mpv
+ -p <path> Play files in <path> instead of the current directory
+ -h Print this help text
+" >&2
+ exit 0
+ ;;
+ ?)
+ echo "Usage: $0 [-h] [-m <opts>] [-p <path>]" >&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))