mpdsrvp
· 926 B · Text
Raw
#!/bin/sh
# mpdsrvp
#
# Serve a MPD instance on a different port already in a partition
# This "adds" partition support for mpd clients that don't support it.
#
# ~jmjl
: "${mpd_srv_addr:="127.0.0.1"}"
: "${mpd_srv_port:="6600"}"
mpm() {
printf '%s\n' "$1" | timeout 0.15 nc "$mpd_srv_addr" "$mpd_srv_port"
}
[ -z "$ca95505c_baa3_4c12_95b3_552426a8aea5_mpdsrvp" ] && {
[ "$#" -lt "1" ] && { printf 'mpdsrvp [add/del/list/(move <part> <out>)] <partition> <port>(,bind=<bind>)\n'; exit 1; }
case "$1" in
"add") mpm "newpartition $2";;
"del") mpm "delpartition $2";;
"list") mpm "listpartitions";;
"move") mpm "partition $2
moveoutput $3";;
*) export ca95505c_baa3_4c12_95b3_552426a8aea5_mpdsrvp="$1"
socat TCP-L:"$2",reuseaddr,fork,nodelay SYSTEM:"$0";;
esac
exit;
}
{ printf 'partition %s\n' "$ca95505c_baa3_4c12_95b3_552426a8aea5_mpdsrvp"; cat; } |\
nc "$mpd_srv_addr" "$mpd_srv_port" |\
sed --unbuffered '2d'
1 | #!/bin/sh |
2 | # mpdsrvp |
3 | # |
4 | # Serve a MPD instance on a different port already in a partition |
5 | # This "adds" partition support for mpd clients that don't support it. |
6 | # |
7 | # ~jmjl |
8 | : "${mpd_srv_addr:="127.0.0.1"}" |
9 | : "${mpd_srv_port:="6600"}" |
10 | |
11 | mpm() { |
12 | printf '%s\n' "$1" | timeout 0.15 nc "$mpd_srv_addr" "$mpd_srv_port" |
13 | } |
14 | |
15 | |
16 | [ -z "$ca95505c_baa3_4c12_95b3_552426a8aea5_mpdsrvp" ] && { |
17 | |
18 | [ "$#" -lt "1" ] && { printf 'mpdsrvp [add/del/list/(move <part> <out>)] <partition> <port>(,bind=<bind>)\n'; exit 1; } |
19 | |
20 | case "$1" in |
21 | "add") mpm "newpartition $2";; |
22 | "del") mpm "delpartition $2";; |
23 | "list") mpm "listpartitions";; |
24 | "move") mpm "partition $2 |
25 | moveoutput $3";; |
26 | *) export ca95505c_baa3_4c12_95b3_552426a8aea5_mpdsrvp="$1" |
27 | socat TCP-L:"$2",reuseaddr,fork,nodelay SYSTEM:"$0";; |
28 | esac |
29 | |
30 | exit; |
31 | } |
32 | |
33 | { printf 'partition %s\n' "$ca95505c_baa3_4c12_95b3_552426a8aea5_mpdsrvp"; cat; } |\ |
34 | nc "$mpd_srv_addr" "$mpd_srv_port" |\ |
35 | sed --unbuffered '2d' |
36 |