dotwryn/bin/pulseaudio

44 lines
1.0 KiB
Plaintext
Raw Normal View History

2022-02-06 07:15:14 +00:00
#!/bin/zsh
source $HOME/.config/wryn/env.zsh
#####################################################################
USAGE="$0 (sink|source) (up|down|mute)"
function ERROR() {
local ERROR_CODE=$1
local MESSAGE="$2"
echo -e "$MESSAGE\n\nUSAGE : $USAGE\n" >&2
exit $ERROR_CODE
}
#####################################################################
DEVICE="$1"
COMMAND="$2"
case $DEVICE in
sink ) AMIXER_DEVICE=Master ;;
source ) AMIXER_DEVICE=Capture ;;
2022-02-06 07:15:14 +00:00
* ) ERROR 1 "Unsupported device '$DEVICE'" ;;
esac
DEFAULT_DEVICE="@DEFAULT_$(echo $DEVICE | tr '[:lower:]' '[:upper:]')@"
case $COMMAND in
up )
2022-02-06 08:08:03 +00:00
pactl set-$DEVICE-volume $DEFAULT_DEVICE +10%
$DOTWRYN/bin/play-sound volume
2022-02-06 07:15:14 +00:00
;;
down )
2022-02-06 08:08:03 +00:00
pactl set-$DEVICE-volume $DEFAULT_DEVICE -10%
$DOTWRYN/bin/play-sound volume
2022-02-06 07:15:14 +00:00
;;
mute )
pactl set-$DEVICE-mute $DEFAULT_DEVICE toggle
$DOTWRYN/bin/play-sound mute
notify-send "default $DEVICE" "$(amixer sget $AMIXER_DEVICE | grep -q '\[on\]' && echo unmuted || echo muted)"
2022-02-06 07:15:14 +00:00
;;
* ) ERROR "Unsupported command '$COMMAND'" ;;
esac