cdwmblocks/blocks.def/volume_button.sh

46 lines
902 B
Bash
Executable File

#!/bin/sh
#SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1
SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo
SINKANALOG=alsa_output.pci-0000_00_1b.0.analog-stereo
checkDefaultSink() {
PACTLOUTPUT=`pactl info`
if echo $PACTLOUTPUT | grep -q "$SINKANALOG"; then
SINK=$SINKANALOG
elif echo $PACTLOUTPUT | grep -q "$SINKHDMI"; then
SINK=$SINKHDMI
fi
}
changeDefaultSink() {
if [ "$SINK" = "$SINKANALOG" ]; then
pactl set-default-sink $SINKHDMI
elif [ "$SINK" = "$SINKHDMI" ]; then
pactl set-default-sink $SINKANALOG
fi
}
managePulsemixer() {
if pgrep "pulsemixer" > /dev/null; then
pkill "pulsemixer"
else
"$TERMINAL" -e "pulsemixer"
fi
}
refreshVolumeBlock() {
sigdwmblocks 2
}
checkDefaultSink
case "$1" in
1) managePulsemixer ;;
2) changeDefaultSink;;
3) pactl set-sink-mute @DEFAULT_SINK@ toggle;;
esac
refreshVolumeBlock