2021-07-28 23:44:53 -07:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2021-10-29 13:14:44 -07:00
|
|
|
m() { rofi -theme ~/SudacodeRice/rofi/rofimpd-desktop.rasi -dmenu -i "$@"; }
|
|
|
|
mb() { rofi -theme ~/SudacodeRice/rofi/rofimpd-desktop.rasi -dmenu -i -kb-custom-1 "Alt+q" "$@"; }
|
2021-07-28 23:44:53 -07:00
|
|
|
|
|
|
|
artist() {
|
|
|
|
lines="$(mpc list artist | wc -l)"
|
|
|
|
[ "$lines" -gt 30 ] && lines=30
|
|
|
|
mpc list artist | sort -f | m -p "Artists" -l $lines
|
|
|
|
}
|
|
|
|
|
|
|
|
a_album() {
|
|
|
|
artist="$1"
|
|
|
|
lines="$(mpc list album artist "$artist" | wc -l)"
|
|
|
|
[ "$lines" -gt 30 ] && lines=30
|
|
|
|
mpc list album artist "$artist" | sort -f | mb -p "Albums" -l $lines
|
|
|
|
}
|
|
|
|
|
|
|
|
album() {
|
|
|
|
lines="$(mpc list album | wc -l)"
|
|
|
|
[ "$lines" -gt 30 ] && lines=30
|
|
|
|
mpc list album | sort -f | mb -p "Album" -l $lines
|
|
|
|
}
|
|
|
|
|
|
|
|
song() {
|
|
|
|
lines="$(mpc list title | wc -l)"
|
|
|
|
[ "$lines" -gt 30 ] && lines=30
|
|
|
|
mpc list title | sort -f | mb -p "Song" -l 30
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
2021-10-29 13:14:44 -07:00
|
|
|
-l | --library) mode=Library ;;
|
|
|
|
-A | --album) mode=Album ;;
|
|
|
|
-s | --song) mode=Song ;;
|
|
|
|
-a | --ask)
|
|
|
|
MODE=$(printf "Library\nAlbum\nSong" | m -p "Choose mode" -l 3)
|
|
|
|
mode=$MODE
|
|
|
|
;;
|
|
|
|
-h | --help)
|
|
|
|
echo "
|
2021-07-28 23:44:53 -07:00
|
|
|
usage: rofi-mpd [-h] [-l] [-s] [-a]
|
|
|
|
|
|
|
|
arguments:
|
|
|
|
-h, --help show this message and exit
|
|
|
|
-l, --library library mode (artist -> album)
|
|
|
|
-A, --album album mode
|
|
|
|
-s, --song song mode (select one song)
|
|
|
|
-a, --ask ask for mode
|
|
|
|
|
|
|
|
bindings:
|
|
|
|
enter play song/album now
|
|
|
|
Alt+q add song/album to queue
|
|
|
|
"
|
2021-10-29 13:14:44 -07:00
|
|
|
exit
|
|
|
|
;;
|
2021-07-28 23:44:53 -07:00
|
|
|
esac
|
|
|
|
|
|
|
|
case "$mode" in
|
2021-10-29 13:14:44 -07:00
|
|
|
Library)
|
|
|
|
artist=$(artist)
|
|
|
|
[ ! "$artist" ] && exit
|
|
|
|
album=$(a_album "$artist")
|
|
|
|
cod=$?
|
|
|
|
[ ! "$album" ] && exit
|
|
|
|
[ "$cod" -eq 10 ] || mpc clear
|
|
|
|
mpc find artist "$artist" album "$album" | mpc add
|
|
|
|
mpc play >/dev/null
|
|
|
|
;;
|
|
|
|
Song)
|
|
|
|
song=$(song)
|
|
|
|
cod=$?
|
|
|
|
[ ! "$song" ] && exit
|
|
|
|
[ "$cod" -eq 10 ] || mpc clear
|
|
|
|
mpc search "(title==\"$song\")" | mpc add
|
|
|
|
mpc play >/dev/null
|
|
|
|
;;
|
|
|
|
Album)
|
|
|
|
album=$(album)
|
|
|
|
cod=$?
|
|
|
|
[ ! "$album" ] && exit
|
|
|
|
[ "$cod" -eq 10 ] || mpc clear
|
|
|
|
mpc find album "$album" | mpc add
|
|
|
|
mpc play >/dev/null
|
|
|
|
;;
|
2021-07-28 23:44:53 -07:00
|
|
|
esac
|