mirror of
https://git.sr.ht/~coasteen/dotfiles
synced 2026-03-21 23:19:22 +01:00
40 lines
1.1 KiB
Bash
40 lines
1.1 KiB
Bash
|
|
#!/usr/bin/env sh
|
||
|
|
|
||
|
|
case "$1" in
|
||
|
|
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) ;;
|
||
|
|
search)
|
||
|
|
choice=$(mpc search any "" | \
|
||
|
|
mpc --format '%title% - %artist% - %album%' search any "" 2>/dev/null | \
|
||
|
|
rofi -dmenu -i -p "Search music")
|
||
|
|
[ -z "$choice" ] && exit 0
|
||
|
|
file=$(mpc --format '%title% - %artist% - %album%\t%file%' search any "" | \
|
||
|
|
grep "^$choice " | head -n 1 | cut -f2)
|
||
|
|
[ -z "$file" ] && exit 0
|
||
|
|
mpc clear
|
||
|
|
mpc add "$file"
|
||
|
|
mpc play
|
||
|
|
;;
|
||
|
|
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")
|
||
|
|
|
||
|
|
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 "Now playing..." "$(mpc current)" -i "$cover"
|