Skip to content

Instantly share code, notes, and snippets.

@0snap
Created November 9, 2019 11:14
Show Gist options
  • Save 0snap/76565e5f90c29a0ad6ce885c63398a32 to your computer and use it in GitHub Desktop.
Save 0snap/76565e5f90c29a0ad6ce885c63398a32 to your computer and use it in GitHub Desktop.
PulseAudio Volume Controller with Sink Selection
#!/bin/sh
# This script determines the currently active pulse audio sink.
# That makes it possible to use the function keys,
# regardless if you are listening via bluetooth, cable, or local speakers.
# Uncomment and add the following to your `.config/i3/config` to bind volume keys (X window)
## bind function keys (fn)
#bindsym XF86AudioRaiseVolume exec --no-startup-id /opt/custom-scripts/volume up
#bindsym XF86AudioLowerVolume exec --no-startup-id /opt/custom-scripts/volume down
#bindsym XF86AudioMute exec --no-startup-id /opt/custom-scripts/volume toggle
sink=$(pactl list sinks | grep -B 1 "RUNNING" | awk -F' #' '{print $2}' | xargs)
if [ "$1" = "up" ]; then
pactl set-sink-volume "$sink" +5%
elif [ "$1" = "down" ]; then
pactl set-sink-volume "$sink" -5%
elif [ "$1" = "toggle" ]; then
pactl set-sink-mute "$sink" toggle
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment