Created
April 18, 2021 02:57
-
-
Save victortrac/186b01564276c2de1f2e99fbc6585707 to your computer and use it in GitHub Desktop.
Pipewire polybar config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.config/polybar/config | |
[module/pulseaudio-devices] | |
type = custom/script | |
label = "%output%" | |
label-font = 2 | |
interval = 2.0 | |
exec = ~/.config/polybar/sound.sh | |
click-right = exec pavucontrol & | |
click-left = ~/.config/polybar/sound.sh mute & | |
scroll-up = ~/.config/polybar/sound.sh up & | |
scroll-down = ~/.config/polybar/sound.sh down & | |
# ~/.config/polybar/sound.sh | |
#!/bin/bash | |
function main() { | |
# Pipewire | |
SOURCE=$(pw-record --list-targets | sed -n 's/^*.*"\(.*\)" prio=.*$/\1/p') | |
SINK=$(pw-play --list-targets | sed -n 's/^*.*"\(.*\)" prio=.*$/\1/p') | |
VOLUME=$(pactl list sinks | sed -n "/${SINK}/,/Volume/ s!^[[:space:]]\+Volume:.* \([[:digit:]]\+\)%.*!\1!p") | |
IS_MUTED=$(pactl list sinks | sed -n "/${SINK}/,/Mute/ s/Mute: \(yes\)/\1/p") | |
action=$1 | |
if [ "${action}" == "up" ]; then | |
pactl set-sink-volume @DEFAULT_SINK@ +10% | |
elif [ "${action}" == "down" ]; then | |
pactl set-sink-volume @DEFAULT_SINK@ -10% | |
elif [ "${action}" == "mute" ]; then | |
pactl set-sink-mute @DEFAULT_SINK@ toggle | |
else | |
if [ "${IS_MUTED}" != "" ]; then | |
echo " ${SOURCE} | MUTED ${SINK}" | |
else | |
echo " ${SOURCE} | ${VOLUME}% ${SINK}" | |
fi | |
fi | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment