#!/usr/bin/env perl use strict; use warnings; use Capture::Tiny qw(capture); use Sys::Hostname qw(hostname); use constant { MIXER_PATH => '/usr/sbin/mixer', NOTIF_PATH => '/usr/local/bin/notify-send' }; sub main { my $rec_vol; my $host; $host = hostname(); if ($host eq "po-rbo.ln.ysosecure.com") { system('/usr/bin/pactl', 'set-source-mute', '@DEFAULT_SOURCE@', 'toggle'); my $muted = `/usr/bin/pactl get-source-mute \@DEFAULT_SOURCE\@ | awk '{print \$2}'`; chomp $muted; if ($muted eq "yes") { system( '/usr/bin/notify-send', '-u', 'low', '-t', '1750', 'mixer-set', ' muted' ); } else { system( '/usr/bin/notify-send', '-u', 'low', '-t', '1750', 'mixer-set', ' restored' ); } exit; } $rec_vol = `mixer rec | awk -F ':' '{print \$2}'`; chomp $rec_vol; if ($rec_vol == 0) { capture { system(MIXER_PATH, 'rec', '100'); }; system( NOTIF_PATH, '-u', 'low', '-t', '1750', 'mixer-set', ' Microphone restored' ); } else { capture { system(MIXER_PATH, 'rec', '0'); system( NOTIF_PATH, '-u', 'low', '-t', '1750', 'mixer-set', ' Microphone muted' ); }; } system('kill -68 $(pidof dwmblocks)'); return; } main(); __END__