From 036c889c4a4f7f59d1e1a592586b54c5c5e93005 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 26 May 2024 20:10:26 +0500 Subject: initial commit --- polybar/scripts/micfn | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 polybar/scripts/micfn (limited to 'polybar/scripts/micfn') 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 -- cgit v1.2.3