diff options
Diffstat (limited to '')
| -rwxr-xr-x | .local/bin/mic | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/.local/bin/mic b/.local/bin/mic index b53c966..67a9bfa 100755 --- a/.local/bin/mic +++ b/.local/bin/mic @@ -3,50 +3,59 @@ 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' + NOTIF_PATH => '/usr/local/bin/herbe' }; -sub main +sub notify +{ + my ($str) = @_; + + my $pid = fork(); + if (not $pid) { + exec(NOTIF_PATH, $str); + } + return; +}; + +sub mic { 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") { + notify('[mic] muted'); + } + else { + notify('[mic] 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' - ); }; + notify('[mic] microphone restored'); } else { capture { system(MIXER_PATH, 'rec', '0'); - system( - NOTIF_PATH, - '-u', - 'low', - '-t', - '1750', - 'mixer-set', - ' Microphone muted' - ); + notify('[mic] microphone muted'); }; } - system('kill -68 $(pidof dwmblocks)'); return; } -main(); +mic(); __END__ |
