#!/bin/sh printhelp() { cat </dev/null 2>&1; then volume="$OPTARG" else printf "%s: invalid number '%s'\n" "${0##*/}" "$OPTARG" exit 1 fi ;; ?) printusage ;; esac done shift $((OPTIND-1)) if [ $# -lt 1 ]; then # set -- "$(. "${XDG_CONFIG_HOME:-"$HOME"/.config}/user-dirs.dirs" && printf '%s' "$XDG_MUSIC_DIR")" set -- . fi prev1= prev2= while true; do file="$(find -L "$@" -type f \( -name '*.m4a' -o -name '*.opus' \) ! -path "$prev1" ! -path "$prev2" -exec shuf -n1 -e '{}' +)" prev1="$prev2" prev2="$file" printf 'Playing %s\n' "${file#$dir/}" mpv --volume="$volume" "$file" done