Last active
December 18, 2015 03:38
-
-
Save JamesTheBard/5719391 to your computer and use it in GitHub Desktop.
Perl script to grab mpd status and information.
This file contains 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/env perl | |
use Switch; | |
# Grab the first line from 'mpc' and throw it into | |
@song = split("\n", `mpc 2>&1`); | |
switch ($song[0]) { | |
case /Connection refused/ { print "MPD not running\n" } | |
case /^volume/ { print "Music playback stopped\n"} | |
else { | |
$time_regex = qr/[0-9]+:[0-9]+/; | |
$playing_regex = qr/\[[a-z]+]/; | |
$song[1] =~ /($playing_regex).+($time_regex)\/($time_regex)/; | |
print "${song[0]} [$2/$3]\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment