dmenu-scripts/dmenu-pulse-port-man

34 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/sh
2022-07-17 11:03:13 +02:00
source $HOME/.config/dmenu/config
2022-08-01 17:52:05 +02:00
portMan () {
notAvailable=$(pactl list sinks | grep 'analog-output-headphones' | grep 'not available')
2022-08-01 17:52:05 +02:00
[ ! -z "$notAvailable" ] && quick-notify "Port Master" "Only one port available" && exit
2022-08-01 17:52:05 +02:00
current=$(pactl list sinks | grep 'Active Port' | awk '{ print $3 }')
[ "$current" = "analog-output-speaker" ] && current="Speakers" || current="Headphones"
2022-08-01 17:52:05 +02:00
case "$(printf "Speakers\\nHeadphones" | $DMENU -p "Current: $current ")" in
"Speakers") pactl set-sink-port 0 analog-output-speaker ;;
esac
}
programVolToggle () {
inputSinks=$(pactl list sink-inputs | sed -e 's/^[ \t]*//' | awk '/^Sink Input/{sink=$3} /^application.name/{name=$3; print name, sink}' )
[ -z "$inputSinks" ] && quick-notify "Program Master" "No Programs Inputing Sound" && exit
programSink=$(printf '%s\n' "$inputSinks" | dmenu -p "Toggle volume: " | awk '{ print $2 }' | sed 's/#//')
2022-08-01 17:52:05 +02:00
pactl set-sink-input-mute $programSink toggle
}
case "$(printf "port\\nprogram" | $DMENU -p "Sound Control: ")" in
port) portMan ;;
program) programVolToggle ;;
*) exit ;;
esac