Quickshell's VolumeOsd now shows changes, so drop notify-send popups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.1 KiB
Bash
Executable File
38 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Volume controls for audio and mic via wpctl (PipeWire).
|
|
# Quickshell's VolumeOsd watches PipeWire directly, so no notifications here.
|
|
|
|
SINK="@DEFAULT_AUDIO_SINK@"
|
|
SOURCE="@DEFAULT_AUDIO_SOURCE@"
|
|
STEP="5%"
|
|
|
|
# Print volume as an integer percent, or "Muted"
|
|
get_volume() {
|
|
local out
|
|
out=$(wpctl get-volume "$1")
|
|
if [[ "$out" == *MUTED* ]]; then
|
|
echo "Muted"
|
|
else
|
|
awk '{ printf "%d %%\n", $2 * 100 + 0.5 }' <<< "$out"
|
|
fi
|
|
}
|
|
|
|
is_muted() {
|
|
[[ "$(wpctl get-volume "$1")" == *MUTED* ]]
|
|
}
|
|
|
|
# Raising/lowering while muted unmutes first, matching the old behaviour
|
|
inc() { is_muted "$1" && wpctl set-mute "$1" 0 || wpctl set-volume -l 1.0 "$1" "$STEP+"; }
|
|
dec() { is_muted "$1" && wpctl set-mute "$1" 0 || wpctl set-volume "$1" "$STEP-"; }
|
|
|
|
case "$1" in
|
|
--inc) inc "$SINK" ;;
|
|
--dec) dec "$SINK" ;;
|
|
--toggle) wpctl set-mute "$SINK" toggle ;;
|
|
--toggle-mic) wpctl set-mute "$SOURCE" toggle ;;
|
|
--mic-inc) inc "$SOURCE" ;;
|
|
--mic-dec) dec "$SOURCE" ;;
|
|
--get-mic) get_volume "$SOURCE" ;;
|
|
*) get_volume "$SINK" ;;
|
|
esac
|