83 lines
1.8 KiB
Bash
Executable File
83 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
ICONlow="🔈"
|
|
ICONmid="🔉"
|
|
ICONhigh="🔊"
|
|
ICONmute="🔇"
|
|
ICONspeakermute="🔕"
|
|
ICONspeaker="🔔"
|
|
ICONheadphone="🎧"
|
|
ICONmicrophone="🎤"
|
|
ICONmicrophonemute="😶"
|
|
ICONmicrophonemute="🤫"
|
|
|
|
#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
|
|
#alsa_output.pci-0000_00_1b.0.analog-surround-51
|
|
|
|
|
|
checkDefaultSink() {
|
|
if [ -v LAPTOP ]; then
|
|
SINK=$SINKANALOG
|
|
return
|
|
fi
|
|
|
|
PACTLOUTPUT="$(pactl get-default-sink)"
|
|
|
|
if echo $PACTLOUTPUT | grep -q "$SINKANALOG"; then
|
|
SINK=$SINKANALOG
|
|
elif echo $PACTLOUTPUT | grep -q "$SINKHDMI"; then
|
|
SINK=$SINKHDMI
|
|
fi
|
|
}
|
|
|
|
if [ -v THINKPAD ]; then
|
|
VOLUME=$(wpctl get-volume @DEFAULT_SINK@ | awk '{printf "%d", $2 * 100}')
|
|
MUTE=$(wpctl get-volume @DEFAULT_SINK@ | grep -q "MUTED" && echo "yes")
|
|
MUTE_SOURCE=$(wpctl get-volume @DEFAULT_SOURCE@ | grep -q "MUTED" && echo "yes")
|
|
else
|
|
VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{printf $5}' | sed s/%//)
|
|
MUTE=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{printf $2}')
|
|
fi
|
|
|
|
checkDefaultSink
|
|
|
|
getIcon() {
|
|
if [ "$MUTE" = "yes" ]; then
|
|
ICON=$ICONmute
|
|
else
|
|
if [ "$VOLUME" -gt "50" ]; then
|
|
ICON=$ICONhigh
|
|
elif [ "$VOLUME" -gt "20" ]; then
|
|
ICON=$ICONmid
|
|
else
|
|
ICON=$ICONlow
|
|
fi
|
|
fi
|
|
|
|
if [ -v THINKPAD ]; then
|
|
MIC_ICON=$ICONmicrophone
|
|
if [ "$MUTE_SOURCE" = "yes" ]; then
|
|
MIC_ICON=$ICONmicrophonemute
|
|
fi
|
|
printf "$ICON %s $MIC_ICON" "$VOLUME%"
|
|
return
|
|
fi
|
|
|
|
echo "?"
|
|
|
|
if [ -v LAPTOP ]; then
|
|
printf "$ICON %s" "$VOLUME%"
|
|
return
|
|
fi
|
|
|
|
if [ "$SINK" = "$SINKHDMI" ]; then
|
|
printf "$ICON %s" "$VOLUME%"
|
|
elif [ "$SINK" = "$SINKANALOG" ]; then
|
|
printf "$ICON %s" "$VOLUME% $ICONheadphone"
|
|
fi
|
|
}
|
|
|
|
getIcon
|