dotfiles-old/.local/scripts/vol.sh

54 lines
1.2 KiB
Bash
Raw Normal View History

2022-03-10 03:42:22 +00:00
#!/bin/sh
PERC="0.05"
2022-03-10 03:42:22 +00:00
refbar() {
pkill sleep -P "$(cat ~/.cache/statusbar_pid )"
}
inc() {
[ "$1" ] && PERC="$1"
#pulsemixer --change-volume +"$1" && refbar
#amixer sset Master 1%+ && refbar
#pamixer -i "$PERC" && refbar
wpctl set-volume @DEFAULT_AUDIO_SINK@ "$(echo "$(get) + $PERC" | bc)" && refbar
2022-03-10 03:42:22 +00:00
}
dec() {
[ "$1" ] && PERC="$1"
#pulsemixer --change-volume -"$1" && refbar
#amixer sset Master 1%- && refbar
#pamixer -d "$PERC" && refbar
wpctl set-volume @DEFAULT_AUDIO_SINK@ "$(echo "$(get) - $PERC" | bc)" && refbar
2022-03-10 03:42:22 +00:00
}
mute() {
#pulsemixer --toggle-mute && refbar
#amixer sset Master toggle && refbar
#pamixer -t && refbar
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && refbar
}
2022-03-10 03:42:22 +00:00
get() {
wpctl get-volume @DEFAULT_AUDIO_SINK@ | cut -d' ' -f 2
2022-03-10 03:42:22 +00:00
}
help() {
2022-07-27 03:11:16 +00:00
echo "-i N -> increment volume by N (0.00 - 1.00)"
echo "-d N -> decrement volume by N (0.00 - 1.00)"
echo "-g -> get current volume"
2022-03-10 03:42:22 +00:00
echo "--toggle-mute -> toggle mute sound"
}
if [ "$1" = "-i" ]; then
inc "$2"
elif [ "$1" = "-d" ]; then
dec "$2"
elif [ "$1" = "--toggle-mute" ]; then
mute
elif [ "$1" = "-g" ]; then
get
2022-03-10 03:42:22 +00:00
else
help
fi