2024-08-09 01:14:56 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
usage() {
|
2024-08-09 01:53:27 +02:00
|
|
|
echo "Usage: $0 [-d|-i|-m|-t]"
|
2024-08-09 01:14:56 +02:00
|
|
|
echo " -d Decrease volume by 10%"
|
|
|
|
echo " -i Increase volume by 10%"
|
2024-08-09 01:53:27 +02:00
|
|
|
echo " -m Toggle mute/unmute for the sink"
|
|
|
|
echo " -t Toggle mute/unmute for the microphone"
|
2024-08-09 01:14:56 +02:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2024-08-09 01:53:27 +02:00
|
|
|
get_default_sink() {
|
|
|
|
pactl info | grep "Default Sink" | awk '{print $3}'
|
|
|
|
}
|
2024-08-09 01:14:56 +02:00
|
|
|
|
2024-08-09 01:53:27 +02:00
|
|
|
get_default_source() {
|
|
|
|
pactl info | grep "Default Source" | awk '{print $3}'
|
|
|
|
}
|
2024-08-09 01:14:56 +02:00
|
|
|
|
2024-08-09 01:53:27 +02:00
|
|
|
while getopts "dimt" opt; do
|
2024-08-09 01:14:56 +02:00
|
|
|
case $opt in
|
|
|
|
d)
|
2024-08-09 01:53:27 +02:00
|
|
|
sink=$(get_default_sink)
|
|
|
|
if [ -n "$sink" ]; then
|
|
|
|
pactl set-sink-volume "$sink" -10%
|
|
|
|
else
|
|
|
|
echo "No default sink found."
|
|
|
|
fi
|
2024-08-09 01:14:56 +02:00
|
|
|
;;
|
|
|
|
i)
|
2024-08-09 01:53:27 +02:00
|
|
|
sink=$(get_default_sink)
|
|
|
|
if [ -n "$sink" ]; then
|
|
|
|
pactl set-sink-volume "$sink" +10%
|
|
|
|
else
|
|
|
|
echo "No default sink found."
|
|
|
|
fi
|
2024-08-09 01:14:56 +02:00
|
|
|
;;
|
|
|
|
m)
|
2024-08-09 01:53:27 +02:00
|
|
|
sink=$(get_default_sink)
|
|
|
|
if [ -n "$sink" ]; then
|
|
|
|
current_mute=$(pactl get-sink-mute "$sink" | awk '{print $2}')
|
|
|
|
if [ "$current_mute" = "yes" ]; then
|
|
|
|
pactl set-sink-mute "$sink" 0
|
|
|
|
echo "Unmuted sink"
|
|
|
|
else
|
|
|
|
pactl set-sink-mute "$sink" 1
|
|
|
|
echo "Muted sink"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "No default sink found."
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
t)
|
|
|
|
source=$(get_default_source)
|
|
|
|
if [ -n "$source" ]; then
|
|
|
|
current_mute=$(pactl get-source-mute "$source" | awk '{print $2}')
|
|
|
|
if [ "$current_mute" = "yes" ]; then
|
|
|
|
pactl set-source-mute "$source" 0
|
|
|
|
echo "Unmuted microphone"
|
|
|
|
else
|
|
|
|
pactl set-source-mute "$source" 1
|
|
|
|
echo "Muted microphone"
|
|
|
|
fi
|
2024-08-09 01:14:56 +02:00
|
|
|
else
|
2024-08-09 01:53:27 +02:00
|
|
|
echo "No default source found."
|
2024-08-09 01:14:56 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2024-08-09 01:53:27 +02:00
|
|
|
sink=$(get_default_sink)
|
|
|
|
if [ -n "$sink" ]; then
|
|
|
|
echo "Current volume for sink:"
|
|
|
|
pactl list sinks | grep -A 15 "$sink" | grep "Volume:"
|
|
|
|
fi
|