Bash script to increase volume beyond 100%. Used as a keyboard shortcut replacement for "Volume up" in Ubuntu.
#!/usr/bin/env bash | |
max=153 | |
current_volume () { | |
pactl list sinks | grep -o "Volume: 0:[[:space:]]\+[0-9]\+" | sed 's/.*[[:space:]]//' | |
} | |
muted () { | |
pactl list sinks | grep "Mute: yes" > /dev/null | |
} | |
new_volume () { | |
cv=$( current_volume ) | |
if muted && [ $cv -gt 0 ]; then | |
echo $cv | |
else | |
cv=$(( $cv + 10 )) | |
if [ $cv -gt $max ]; then | |
echo $max | |
else | |
echo $cv | |
fi | |
fi | |
} | |
set_volume () { | |
pactl set-sink-volume 0 $1% | |
pactl set-sink-mute 0 0 | |
} | |
icon () { | |
if [ $1 -lt 30 ]; then | |
level=low | |
elif [ $1 -lt 70 ]; then | |
level=medium | |
else | |
level=high | |
fi | |
echo notification-audio-volume-$level | |
} | |
notify_volume_change () { | |
notify-send " " -h string:synchronous:volume -i $( icon $1 ) -h int:value:$1 | |
playsound_simple /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga > /dev/null | |
} | |
nv=$( new_volume ) | |
set_volume $nv | |
notify_volume_change $nv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment