summaryrefslogtreecommitdiff
path: root/polybar/scripts/micfn
blob: bebe7d619ccd648f3b6bef8f412db6e1886fa631 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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