From ca59154e185d617ce9692e85484f423beddb2d20 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 14 Apr 2022 11:09:27 +0200 Subject: new script to toggle mic in mixer --- .local/bin/mic | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 .local/bin/mic (limited to '.local/bin') diff --git a/.local/bin/mic b/.local/bin/mic new file mode 100755 index 0000000..41e6470 --- /dev/null +++ b/.local/bin/mic @@ -0,0 +1,51 @@ +#!/usr/local/bin/perl + +use strict; +use warnings; +use Capture::Tiny qw(capture); + +use constant { + MIXER_PATH => '/usr/sbin/mixer', + NOTIF_PATH => '/usr/local/bin/notify-send' +}; + +sub main +{ + my $rec_vol; + + $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' + ); + }; + } + return; +} + +main(); + +__END__ -- cgit v1.2.3