diff options
| author | ilotterytea <ilotterytea@proton.me> | 2024-05-26 20:10:26 +0500 |
|---|---|---|
| committer | ilotterytea <ilotterytea@proton.me> | 2024-05-26 20:10:26 +0500 |
| commit | 036c889c4a4f7f59d1e1a592586b54c5c5e93005 (patch) | |
| tree | aa76d678790abc79f24edf83c17a564eb2c6f65d /polybar/scripts/micfn | |
Diffstat (limited to 'polybar/scripts/micfn')
| -rwxr-xr-x | polybar/scripts/micfn | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/polybar/scripts/micfn b/polybar/scripts/micfn new file mode 100755 index 0000000..bebe7d6 --- /dev/null +++ b/polybar/scripts/micfn @@ -0,0 +1,34 @@ +#!/bin/sh + +function helpfn() { + echo "micfn, a quick mic toggle script" +} + +active_port=$(pactl list | sed -n '/^Source/,/^$/p' | grep 'Active Port' | cut -d ' ' -f3) + +if amixer get Capture | grep "\[off\]" > /dev/null +then + status="OFF" +else + status="ON" +fi + +function toggle() { + amixer set Capture toggle > /dev/null + if amixer get Capture | grep "\[off\]" > /dev/null + then + notify-send -t 3000 "$active_port" "Microphone OFF" + else + notify-send -t 3000 "$active_port" "Microphone ON" + fi +} + +if [ "$1" == "-h" -o "$1" == "--help" ]; then + helpfn + exit 0 +elif [ "$1" == "-t" -o "$1" == "--toggle" ]; then + toggle + exit 0 +elif [ $# -eq 0 ]; then + echo $status +fi |
