dotfiles-mirror/local/bin/mpc-shuf.sh

33 lines
1.5 KiB
Bash
Raw Normal View History

2026-02-21 01:27:19 +03:30
#!/usr/bin/env sh
case "$1" in
2026-02-21 04:51:46 +03:30
shuf) mpc random on && notify-send "Shuffle enabled" && exit 0 ;;
shufno) mpc random off && notify-send "Shuffle disabled" && exit 0 ;;
next) mpc next ;;
prev) mpc prev ;;
current) mpc current && exit 0 ;;
info)
song_file=$(mpc --format '%file%' current)
song_dir=$(dirname "/home/coast/Music/$song_file")
cover=$(find "$song_dir" -maxdepth 1 \( -iname '*cover*.jpg' -o -iname '*cover*.png' -o -iname '*folder*.jpg' -o -iname '*folder*.png' -o -iname '*front*.jpg' -o -iname '*front*.png' \) | head -n 1)
[ -z "$cover" ] && cover="/usr/share/icons/hicolor/48x48/apps/musical-note.png"
notify-send "Currently Playing" "$(mpc current)" -i "$cover" && exit 0
;;
2026-02-21 01:27:19 +03:30
search)
2026-02-21 04:51:46 +03:30
choice=$(mpc --format '%title% - %artist% - %album%\t%file%' search any "" \
| rofi -dmenu -i -p "Search music" -display-columns 1)
2026-02-21 01:27:19 +03:30
[ -z "$choice" ] && exit 0
2026-02-21 04:51:46 +03:30
file=$(printf '%s' "$choice" | cut -f2)
2026-02-21 01:27:19 +03:30
[ -z "$file" ] && exit 0
2026-02-21 04:51:46 +03:30
mpc clear && mpc add "$file" && mpc play && exit 0
2026-02-21 01:27:19 +03:30
;;
esac
mpc play
mpc volume 15
song_file=$(mpc --format '%file%' current)
music_dir="/home/coast/Music"
song_abs="$music_dir/$song_file"
song_dir=$(dirname "$song_abs")
2026-02-21 04:51:46 +03:30
cover=$(find "$song_dir" -maxdepth 1 \( -iname '*cover*.jpg' -o -iname '*cover*.png' -o -iname '*folder*.jpg' -o -iname '*folder*.png' -o -iname '*front*.jpg' -o -iname '*front*.png' \) | head -n 1)
2026-02-21 01:27:19 +03:30
[ -z "$cover" ] && cover="/usr/share/icons/hicolor/48x48/apps/musical-note.png"
notify-send "Now playing..." "$(mpc current)" -i "$cover"