diff options
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/dmpc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/.local/bin/dmpc b/.local/bin/dmpc index 0e3f826..311a30d 100755 --- a/.local/bin/dmpc +++ b/.local/bin/dmpc @@ -1,21 +1,33 @@ #!/usr/local/bin/perl +use strict; +use warnings; + sub main { my $action; my $current; my $prompt; + my $queued; - $current = `mpc`; - if ($current =~ /volume: n\/a/) { - $current = "Current: Stopped"; + $current = `mpc current`; + if (not $current) { + $current = 'Current: Stopped'; + } + else { + $current = 'Current: ' . $current; + } + $queued = `mpc queued`; + if ($current eq 'Current: Stopped' || not $queued) { + $queued = 'Next: None'; } else { - $current =~ /$\.+/d; - $current = "Current: " . $current; + $queued = 'Next: ' . $queued; } - $prompt = "toggle\nstop\nnext\nprev\n$current\n"; - $action = `printf '$prompt' | dmenu`; + chomp $current; + chomp $queued; + $prompt = "toggle\nnext\nprev\nplay\nstop\nclear\nrepeat\nrandom\n\n$current\n$queued\n"; + $action = `printf '$prompt' | dmenu -i -l 11 -m 0`; system("mpc " . $action); return; } |