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 | source ) ;;
|
|
|
|
* ) 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%
|
2022-08-22 22:40:57 +00:00
|
|
|
$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%
|
2022-08-22 22:40:57 +00:00
|
|
|
$DOTWRYN/bin/play-sound volume
|
2022-02-06 07:15:14 +00:00
|
|
|
;;
|
|
|
|
mute )
|
|
|
|
pactl set-$DEVICE-mute $DEFAULT_DEVICE toggle
|
2022-08-22 22:40:57 +00:00
|
|
|
$DOTWRYN/bin/play-sound mute
|
2022-02-06 07:15:14 +00:00
|
|
|
notify-send "default $DEVICE" "$(amixer sget Master | grep -q '\[on\]' && echo unmuted || echo muted)"
|
|
|
|
;;
|
|
|
|
* ) ERROR "Unsupported command '$COMMAND'" ;;
|
|
|
|
esac
|