Last active
August 29, 2015 14:11
-
-
Save tsumare/d582b4b49c49727cb707 to your computer and use it in GitHub Desktop.
Pulseaudio Application Mute Toggle Script
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/perl | |
use warnings; | |
use strict; | |
open(PALIST, '-|', 'pacmd list-sink-inputs'); | |
my $index = undef; | |
my $set_mute_to = undef; | |
while (<PALIST>) { | |
if (/^\s*index: ([0-9]+)$/) { | |
$index = $1; | |
} | |
if (/^\s*muted: (yes|no)$/) { | |
$set_mute_to = 1; | |
$set_mute_to = 0 if ($1 eq 'yes'); | |
} | |
if (/^\s*application\.name = "(.*)"$/) { | |
if ($1 eq $ARGV[0]) { | |
system('pacmd', 'set-sink-input-mute', $index, $set_mute_to); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment