X-Git-Url: https://git.xandkar.net/?p=khatus.git;a=blobdiff_plain;f=x4%2Fbin%2Fkhatus_x4_sensor_mpd;fp=x4%2Fbin%2Fkhatus_x4_sensor_mpd;h=cc295956850dbd3e5dd984565a7a9562e00b493c;hp=0000000000000000000000000000000000000000;hb=4411059d155436af0e80e5e6c3928ac8373093d6;hpb=dd5287c68654c8c82b3974364d210fdcc253f9d2 diff --git a/x4/bin/khatus_x4_sensor_mpd b/x4/bin/khatus_x4_sensor_mpd new file mode 100755 index 0000000..cc29595 --- /dev/null +++ b/x4/bin/khatus_x4_sensor_mpd @@ -0,0 +1,27 @@ +#! /bin/sh + +set -e + +bin_dir="$(dirname $(realpath $0))" + +. "$bin_dir/khatus_x4_lib_common_sensor.sh" + +sensor() { + # TODO: Convert mpd sensor to watcher from poller + # Since we can just open the connection and send periodic requests. + # + # close + # Closes the connection to MPD. MPD will try to send the remaining output + # buffer before it actually closes the connection, but that cannot be + # guaranteed. This command will not generate a response. + # + # Clients should not use this command; instead, they should just close the socket. + # + # https://www.musicpd.org/doc/html/protocol.html#connection-settings + # + echo 'status\ncurrentsong\nclose' \ + | nc 127.0.0.1 6600 \ + | "$bin_dir"/khatus_x4_parse_mpd_status_currentsong +} + +run