Skip to content

Instantly share code, notes, and snippets.

@tsumare
Last active August 29, 2015 14:11
Show Gist options
  • Save tsumare/d582b4b49c49727cb707 to your computer and use it in GitHub Desktop.
Save tsumare/d582b4b49c49727cb707 to your computer and use it in GitHub Desktop.
Pulseaudio Application Mute Toggle Script
#!/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