rice/scripts/rofi-mpd-desktop

86 lines
1.9 KiB
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env sh
m() { rofi -theme -dmenu -config ~/SudacodeRice/rofi/dracula.rasi -l 24 -i "$@"; }
mb() { rofi -dmenu -config ~/SudacodeRice/rofi/dracula.rasi -l 24 -i -kb-custom-1 "Alt+q" "$@"; }
artist() {
2022-01-27 23:29:01 -08:00
lines="$(mpc list artist | wc -l)"
[ "$lines" -gt 30 ] && lines=30
mpc list artist | sort -f | m -p "Artists" -l $lines
}
a_album() {
2022-01-27 23:29:01 -08:00
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() {
2022-01-27 23:29:01 -08:00
lines="$(mpc list album | wc -l)"
[ "$lines" -gt 30 ] && lines=30
mpc list album | sort -f | mb -p "Album" -l $lines
}
song() {
2022-01-27 23:29:01 -08:00
lines="$(mpc list title | wc -l)"
[ "$lines" -gt 30 ] && lines=30
mpc list title | sort -f | mb -p "Song" -l 30
}
case "$1" in
2022-01-27 23:29:01 -08: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 "
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
"
2022-01-27 23:29:01 -08:00
exit
;;
esac
case "$mode" in
2022-01-27 23:29:01 -08: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
;;
esac