Yet another approach to volume/mute control.

This commit is contained in:
Bartek Stalewski 2021-08-23 20:25:41 +02:00
parent 9fcfdbad32
commit 4865f4f572
3 changed files with 45 additions and 41 deletions

26
_suckless/_scripts/dmenu-audio Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
set_out() {
sinks=$(pamixer --list-sinks | grep -v '^Sinks:$' | awk -F'"' '{print $4}')
sel_sink=$(printf "$sinks" | dmenu -l 10 -i -p "wut")
pactl set-default-sink $(pamixer --list-sinks | grep "$sel_sink" | awk '{print $1}')
kill -46 $(pidof dwmblocks)
}
set_in() {
sources=$(pamixer --list-sources | grep -v '^Sources:$' | grep -v 'Monitor of ' | awk -F'"' '{print $4}')
sel_source=$(printf "$sources" | dmenu -l 10 -i -p "wut")
pactl set-default-source $(pamixer --list-sources | grep "$sel_source" | awk '{print $1}')
kill -46 $(pidof dwmblocks)
}
sinks=$(pamixer --list-sinks | grep -v '^Sinks:$' | awk -F'"' '{print $4}')
[ "$(echo "$sinks" | wc -l)" -lt 2 ] &&
{ notify-send "🔊 Only one sink detected."; exit; }
chosen=$(printf "output\\ninput" | dmenu -i -p "What to change:")
case "$chosen" in
output) set_out ;;
input) set_in ;;
*) exit 1 ;;
esac