dotwryn/bin/pulseaudio
2022-02-06 01:08:03 -07:00

43 lines
949 B
Bash
Executable File

#!/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 | source ) ;;
* ) ERROR 1 "Unsupported device '$DEVICE'" ;;
esac
DEFAULT_DEVICE="@DEFAULT_$(echo $DEVICE | tr '[:lower:]' '[:upper:]')@"
case $COMMAND in
up )
pactl set-$DEVICE-volume $DEFAULT_DEVICE +10%
PLAY_SFX volume
;;
down )
pactl set-$DEVICE-volume $DEFAULT_DEVICE -10%
PLAY_SFX volume
;;
mute )
pactl set-$DEVICE-mute $DEFAULT_DEVICE toggle
PLAY_SFX mute
notify-send "default $DEVICE" "$(amixer sget Master | grep -q '\[on\]' && echo unmuted || echo muted)"
;;
* ) ERROR "Unsupported command '$COMMAND'" ;;
esac