Skip to content

Commit

Permalink
Updated mpdcontrol with the nowartist and nowalbum commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
uriel1998 committed Dec 13, 2024
1 parent ac735e5 commit ebe0857
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ One or more of the following:

# mpdcontrol.sh

Select whether you want to choose a playlist, or by album, artist, or genre. Clears playlist (IF YOU USE THE SWITCH -c), adds what you chose, starts playing. The SSH version is for exactly that, especially if you don't have `pick` on that machine.
Select whether you want to choose a playlist, or by album, artist, or genre. Clears playlist (IF YOU USE THE SWITCH -c), adds what you chose, starts playing. Optionally, if `fzf` is installed on the system, it will seamlessly substitute that program in, with the option to select multiple entries at once (use TAB).

Optionally, if `fzf` is installed on the system, it will seamlessly substitute that program in, with the option to select multiple entries at once (use TAB).
You can also use the command line argument `nowalbum` or `nowartist` to add the currently playing album or all of the album artist's tracks to the queue (put `-c` first to have it clear the queue first).

The SSH version is for exactly that, especially if you don't have `pick` on that machine.
The `mpdcontrol_add.sh` file does *not* clear the queue so that you can add to the existing playlist.

Dependencies:
Expand Down
5 changes: 3 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ One or more of the following:

# mpdcontrol.sh

Select whether you want to choose a playlist, or by album, artist, or genre. Clears playlist (IF YOU USE THE SWITCH -c), adds what you chose, starts playing. The SSH version is for exactly that, especially if you don't have `pick` on that machine.
Select whether you want to choose a playlist, or by album, artist, or genre. Clears playlist (IF YOU USE THE SWITCH -c), adds what you chose, starts playing. Optionally, if `fzf` is installed on the system, it will seamlessly substitute that program in, with the option to select multiple entries at once (use TAB).

Optionally, if `fzf` is installed on the system, it will seamlessly substitute that program in, with the option to select multiple entries at once (use TAB).
You can also use the command line argument `nowalbum` or `nowartist` to add the currently playing album or all of the album artist's tracks to the queue (put `-c` first to have it clear the queue first).

The SSH version is for exactly that, especially if you don't have `pick` on that machine.
The `mpdcontrol_add.sh` file does *not* clear the queue so that you can add to the existing playlist.

Dependencies:
Expand Down
55 changes: 54 additions & 1 deletion mpdcontrol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,40 @@ ADDMODE="1"

if [ "$1" == "-c" ];then
ADDMODE="0"
shift
fi

now_album(){

artist=$(mpc --host "$MPD_HOST" current --format "%artist%")
album=$(mpc --host "$MPD_HOST" current --format "%album%")


if [[ -z "$artist" || -z "$album" ]]; then
echo "No song is currently playing."
else
clearmode
mpc --host "$MPD_HOST" search album "$album" | mpc add
mpc --host "$MPD_HOST" play
fi
}

now_artist(){

album_artist=$(mpc --host "$MPD_HOST" current --format "%albumartist%")
if [[ -z "$album_artist" ]]; then
echo "No song is currently playing or no album artist information available."
else
clearmode
mpc --host "$MPD_HOST" search albumartist "$album_artist" | mpc add
mpc --host "$MPD_HOST" play
fi

}





clearmode (){

Expand All @@ -26,10 +59,14 @@ clearmode (){
fi
}



interactive(){

echo -e "\E[0;32m(\E[0;37mc\E[0;32m)ustom, \E[0;32m(\E[0;37mg\E[0;32m)enre, (\E[0;37mA\E[0;32m)lbumartist, (\E[0;37ma\E[0;32m)rtist, a(\E[0;37ml\E[0;32m)bum, (\E[0;37ms\E[0;32m)ong, (\E[0;37mp\E[0;32m)laylist, or (\E[0;37mq\E[0;32m)uit? "; tput sgr0
read -r CHOICE


case "$CHOICE" in
"c")
if [ -f "$(which fzf)" ];then
Expand Down Expand Up @@ -149,3 +186,19 @@ clearmode (){
"h") echo "Use -c to clear before adding. Export your MPD_HOST as PASS@HOST; localhost is default";;
*) echo "You have chosen poorly. Run without commandline input.";;
esac
}


case "${1}" in
nowal*|now_al*)
now_album
;;
nowar*|now_ar*)
now_artist
;;
-c) ADDMODE="0"
shift
;;
*) interactive "${@}"
;;
esac

0 comments on commit ebe0857

Please sign in to comment.