32 lines
883 B
Bash
Executable File
32 lines
883 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "$1" = "status" ]; then
|
|
state=$(amixer sget Capture | grep "\[on\]")
|
|
if [ -n "$state" ]; then
|
|
echo "no"
|
|
else
|
|
echo "yes"
|
|
fi
|
|
elif [ "$1" = "toggle" ]; then
|
|
state=$(amixer sget Capture | grep "\[on\]")
|
|
if [ -n "$state" ]; then
|
|
amixer sset Capture nocap
|
|
echo "no"
|
|
else
|
|
amixer sset Capture cap
|
|
echo "yes"
|
|
fi
|
|
elif [ "$1" = "set" ] && [ "$2" -gt 0 ] && [ "$2" -le 100 ]; then
|
|
volume="$2%"
|
|
amixer sset Capture "${volume}"
|
|
echo "Volume set to ${volume}"
|
|
elif [ "$1" = "get" ]; then
|
|
(( mic_vol = $(amixer sget Capture | grep -oE '[0-9]+%' | tr -d '%') * 100 / 100 ))
|
|
echo $mic_vol
|
|
elif [ "$1" = "percent" ] && [ "$2" -gt 0 ] && [ "$2" -le 100 ]; then
|
|
amixer sset Capture "${2}%"
|
|
echo "Volume set to ${2}%"
|
|
else
|
|
echo "Usage: $0 [status|toggle|set|get|percent]"
|
|
fi
|