#!/bin/sh # . :-. . # author: ratakor :*==*%%%#%+=---: # :#%%%*+%#=+%*:. # created: Sat, 06 May 2023 18:44:52 +0200 :%%%. . -*%- # updated: Sat, 22 Jul 2023 00:27:35 +0200 =## . :#%*=:. # -#*#%:=#%%%#- # description: *:*%%%%%%%#- # simple music selector with dmenu that uses and .-#%%%%%%+ # interacts with mpv. have a look at musiccmd, %%%--%%%%*- # dwmblocks/sb_music and .local/etc/mpv/music ;) ##%= +%%=:.. # #* #%# # :# -==* # shellcheck disable=SC2012 # :: .: MUSICDIR="${XDG_MUSIC_DIR:-$HOME/music}" if [ "$1" = "--shuffle" ]; then SHUFFLE=yes shift fi MUSIC="${1:-$MUSICDIR/$(ls "$MUSICDIR" | dmenu -i -p "Play ")}" SCRIPT="${XDG_CONFIG_HOME:-$HOME/.config}/mpv/music/local.lua" if [ "$MUSIC" = "$MUSICDIR/urls" ]; then MUSIC="$(cat "$MUSICDIR/urls/$(ls "$MUSICDIR/urls" | dmenu -i -p "Play ")")" SCRIPT="${XDG_CONFIG_HOME:-$HOME/.config}/mpv/music/online.lua" fi [ "$MUSIC" = "$MUSICDIR/" ] || [ -z "$MUSIC" ] && exit 1 if [ -z "$SHUFFLE" ] && [ -d "$MUSIC" ] || printf '%s' "$MUSIC" | grep -q playlist; then SHUFFLE="$(printf 'yes\nno' | dmenu -i -p 'Shuffle?')" [ -z "$SHUFFLE" ] && exit 1 fi printf 'stop\n' | socat - /tmp/mpvsocket 2> /dev/null mpv --vid=auto --input-ipc-server=/tmp/mpvsocket --loop-playlist\ --ytdl-format=ba --script="$SCRIPT" --shuffle="$SHUFFLE" "$MUSIC"