]> git.draconx.ca Git - mpdhacks.git/blobdiff - MPDHacks.pm
mpdthumb: Fix failure when readpicture/albumart both return data.
[mpdhacks.git] / MPDHacks.pm
index 94c0acc518dbad5067eb1c4456c4877ee169955d..7da3b06b7e5258a0413b0b7b17f518e20a1175f7 100644 (file)
@@ -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;