-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmpdcontrol_ssh.sh
executable file
·54 lines (48 loc) · 2.04 KB
/
mpdcontrol_ssh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
################################################################################
# A simple utility to allow playlist selection and playing from cli for MPD
#
# by Steven Saus
#
# Licensed under a Creative Commons BY-SA 3.0 Unported license
# To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/.
#
# This is an example of how to utilize the script over SSH. In this example, keyfile
# pairing is already set up. steven is the username, wombat.local is the remote server
#
################################################################################
echo -e "\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
"s")
if [ -f "$(which fzf)" ];then
result=$(mpc --host "$MPD_HOST" list title | fzf --multi)
else
result=$(mpc --host "$MPD_HOST" list title | pick)
fi
clearmode
while IFS= read -r title; do
mpc --host "$MPD_HOST" findadd title "${title}"
mpc --host "$MPD_HOST" play
done <<< "$result"
;;
"a")
artist=$(ssh [email protected] 'mpc list artist' | pick)
ssh [email protected] "mpc clear -q; mpc findadd artist '$artist';mpc shuffle -q;mpc play"
;;
"l")
album=$(ssh [email protected] 'mpc list album' | pick)
ssh [email protected] "mpc clear -q; mpc findadd album '$album';mpc random off ;mpc play"
;;
"g")
genre=$(ssh [email protected] 'mpc list genre' | pick)
ssh [email protected] "mpc clear -q;mpc findadd genre '$genre';mpc shuffle -q;mpc play"
;;
"p")
playlist=$(ssh [email protected] 'mpc lsplaylists'| pick)
ssh [email protected] "mpc clear -q;mpc load '$playlist';mpc shuffle -q;mpc play"
;;
"q")
;;
*) echo "You have chosen poorly. Run without commandline input."
esac