Last active 1726527644

Julian Marcos revised this gist 1726527641. Go to revision

1 file changed, 35 insertions

mpdsrvp(file created)

@@ -0,0 +1,35 @@
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'
Newer Older