nix-dotfiles/scripts/changevolume.sh

24 lines
854 B
Bash
Raw Permalink Normal View History

#!/bin/bash
# Usage: changevolume.sh <device> <-1|0|1>
# First argument: device as in wpctl, e.g. @DEFAULT_AUDIO_SINK@ or @DEFAULT_AUDIO_SOURCE@
# Second argument: reduce (-1), toggle mute (0), increase (1)
if [[ $2 -eq 0 ]] then
wpctl set-mute $1 toggle
if [[ -f $(which dunstify) ]] then
dunstify -a "changevolume.sh" -u low -i weather-clear -h string:x-dunst-stack-tag:changebrightness "Device $1 mute toggled"
fi
exit 0
fi
if [[ $2 -eq 1 ]] then
wpctl set-volume $1 0.05+
if [[ -f $(which dunstify) ]] then
dunstify -a "changevolume.sh" -u low -i weather-clear -h string:x-dunst-stack-tag:changebrightness "Device $1 mute toggled"
fi
fi
if [[ -f $(which dunstify) ]] then
dunstify -a "changevolume.sh" -u low -i audio-volume-medium -h string:x-dunst-stack-tag:changevolume $(wpctl get-volume $1)
fi