X-Git-Url: https://git.draconx.ca/gitweb/mpdhacks.git/blobdiff_plain/b0f5f5741b234174958ade58a6e884df8b6b00e4..HEAD:/MPDHacks.pm diff --git a/MPDHacks.pm b/MPDHacks.pm index 94c0acc..7da3b06 100644 --- a/MPDHacks.pm +++ b/MPDHacks.pm @@ -107,4 +107,22 @@ sub escape { return $s; } +# Submit a command to the MPD server; each argument to this function +# is quoted and sent as a single argument to MPD. +sub exec { + my $cmd = join(' ', map { MPD::escape } @_); + + print $sock "$cmd\n"; +} + +# Submit a command to the MPD server and wait for it to complete. +# Intended for simple cases where the command output is unneeded. +sub run { + MPD::exec(@_); + while (<$sock>) { + last if (/^OK/); + die($_) if (/^ACK/); + } +} + 1;