dotfiles/etc/acpi/volume.sh
2023-10-03 13:56:53 +02:00

27 lines
596 B
Bash
Executable File

#!/usr/bin/bash
sinks=$(pactl list sinks short | grep RUNNING | awk '{ print $1 }')
if [ -z "$sinks" ]; then
sinks=$(pactl get-default-sink)
fi
echo "$sinks"
for SINK in $sinks
do
volume="${1//\%/}"
if [[ $volume =~ \+ ]] || [[ $volume =~ - ]]; then
current=$(pactl get-sink-volume "${SINK}" | grep -o -E "[0-9]+%" | head -1 | sed "s/%//g")
volume="$((${current} ${volume}))"
if [[ "${volume}" =~ "-" ]]; then
volume="0"
fi
#if [ "${#volume}" -gt "2" ]; then
# volume="100"
#fi
fi
echo "$volume"
pactl set-sink-volume "${SINK}" "${volume}%"
done