dotfiles/_suckless/_scripts/sb-volume

20 lines
984 B
Bash
Executable File

#!/bin/bash
if [ "${1}" = "micmute" ]; then
case $(cat '/sys/devices/platform/thinkpad_acpi/leds/platform::micmute/brightness') in
1) echo 0 | sudo tee /sys/devices/platform/thinkpad_acpi/leds/platform::micmute/brightness;;
0) echo 1 | sudo tee /sys/devices/platform/thinkpad_acpi/leds/platform::micmute/brightness;;
esac
for i in $(pactl list short sources | grep -v '\.monitor' | awk '{print $1}'); do
pactl set-source-mute "${i}" toggle
done
kill -46 $(pidof dwmblocks)
else
vol="$(pamixer --get-volume)"
[ $(echo $vol | wc -c) -lt 4 ] && svol=" ${vol}%%" || svol="${vol}%%"
[ $(pamixer --get-mute) = true ] && volinfo="^c#eeeeee^^b#005577^\ue04f mute^d^" || volinfo="\ue050 ${svol}"
device=$(pamixer --list-sources | grep -v '^Sources:$' | grep -v 'Monitor of ' | head -n 1 | awk '{print $1}')
[ $(pamixer --source $device --get-mute) = true ] && micinfo="^c#eeeeee^^b#005577^\ue02b^d^" || micinfo="\ue02a^d^"
printf "${micinfo} ${volinfo}"
fi