Created
March 20, 2017 21:33
-
-
Save trygveaa/d512cad510cbc3a92cafeea8c567ea12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use utf8; | |
use IO::Socket::INET6; | |
my $current_song; | |
if (my $server = IO::Socket::INET6->new(PeerAddr => ($ARGV[0] or 'localhost'), PeerPort => ($ARGV[1] or '6600'), Proto => 'tcp', Timeout => 5)) { | |
print $server "currentsong\n"; | |
print $server "idle player\n"; | |
while (<$server>) { | |
if (/^file: (.*)/) { | |
if ($current_song) { | |
if ($1 ne $current_song) { | |
print $server "noidle\n"; | |
print $server "pause 1\n"; | |
sleep 5; | |
print $server "pause 0\n"; | |
print $server "idle player\n"; | |
} | |
} | |
$current_song = $1; | |
} elsif (/^changed:/) { | |
print $server "currentsong\n"; | |
print $server "idle player\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment