#!/bin/sh # Musmaster: find and play music in any directory # Depends on find and fzf # Created by Luxferre in 2026, released into the public domain [ -z "$PLAYER" ] && PLAYER='mpg123' [ -z "$FTYPES" ] && FTYPES='mp3 MP3' if [ -z "$TAGDUMP" ]; then TAGDUMP='mpg123-id3dump -n {} | grep -E "^(Title|Artist|Album|Year|Comment|Genre):" | sort -u' fi mdir="$1" [ -z "$mdir" ] && mdir='.' set -- for ext in $FTYPES; do if [ $# -eq 0 ]; then set -- -name "*.$ext" else set -- "$@" -o -name "*.$ext" fi done cd "$mdir" muslist="$(find . -type f \( "$@" \))" dirlist="$(find . -type f \( "$@" \) -print0 | xargs -0 dirname | sort -u)" muslist="$(printf '%s\n%s' "$muslist" "$dirlist" | sort -u)" PREVIEWCMD="[ -d {} ] && ls -1 {} || ([ {} != 'Quit' ] && $TAGDUMP)" while true; do src="$(printf '%s\nQuit' "$muslist" | grep . | fzf --tac --preview="$PREVIEWCMD" -0 -1)" [ -d "$src" ] && src="$(find "$src" -type f \( "$@" \) | sort -u)" [ "$src" = 'Quit' ] && break if [ -n "$src" ]; then printf '%s\n' "$src" | while read -r track; do $PLAYER "$track" done fi done