mirror of https://gitlab.com/dabruh/dotfiles.git
Improved support for muting sources.
This commit is contained in:
parent
70cf73dc8c
commit
f1344b61d2
|
@ -1,8 +1,8 @@
|
||||||
# Use pactl to adjust volume in PulseAudio.
|
# Use pactl to adjust volume in PulseAudio.
|
||||||
bindsym XF86AudioRaiseVolume exec --no-startup-id pavolctl +10%
|
bindsym XF86AudioRaiseVolume exec --no-startup-id pavolctl +10%
|
||||||
bindsym XF86AudioLowerVolume exec --no-startup-id pavolctl -10%
|
bindsym XF86AudioLowerVolume exec --no-startup-id pavolctl -10%
|
||||||
bindsym XF86AudioMute exec --no-startup-id pavolctl set-sink-mute
|
bindsym XF86AudioMute exec --no-startup-id pavolctl toggle Master
|
||||||
bindsym XF86AudioMicMute exec --no-startup-id pavolctl set-source-mute
|
bindsym XF86AudioMicMute exec --no-startup-id pavolctl toggle Capture
|
||||||
|
|
||||||
# Set cmus controls
|
# Set cmus controls
|
||||||
bindsym XF86AudioStop exec --no-startup-id "cmusctl -c stop"
|
bindsym XF86AudioStop exec --no-startup-id "cmusctl -c stop"
|
||||||
|
|
|
@ -1,29 +1,35 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SINK="@DEFAULT_SINK@"
|
PULSEAUDIO_SINK="${PULSEAUDIO_SINK:-"@DEFAULT_SINK@"}"
|
||||||
LIMIT=150
|
VOLUME_LIMIT="${VOLUME_LIMIT:-150}"
|
||||||
ADJUSTMENT=$1
|
|
||||||
|
TARGET="$1"
|
||||||
|
ADJUSTMENT="$2"
|
||||||
|
|
||||||
|
echo "${TARGET:?} ${ADJUSTMENT:?}" >/dev/null
|
||||||
|
|
||||||
function limit_level() {
|
function limit_level() {
|
||||||
level="$(pactl get-sink-volume "$SINK" | grep '^Volume' | cut -d' ' -f5 | grep -o "[[:digit:]]*")"
|
level="$(pactl get-sink-volume "$PULSEAUDIO_SINK" | grep '^Volume' | cut -d' ' -f5 | grep -o "[[:digit:]]*")"
|
||||||
|
|
||||||
if [[ "$level" -gt "$LIMIT" ]]; then
|
if [[ "$level" -gt "$VOLUME_LIMIT" ]]; then
|
||||||
echo "Limiting volume to: $1"
|
echo "Limiting volume to: $1"
|
||||||
set_level $LIMIT%
|
set_level $VOLUME_LIMIT%
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_level() {
|
function set_level() {
|
||||||
echo "Desired volume adjustment: $1"
|
echo "Desired volume adjustment: $1"
|
||||||
pactl set-sink-volume "$SINK" "$1"
|
pactl set-sink-volume "$PULSEAUDIO_SINK" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$ADJUSTMENT" == set-*-mute ]]; then
|
if [[ "$TARGET" == "volume" ]]; then
|
||||||
echo "Desired volume adjustment: $1"
|
|
||||||
pactl "$ADJUSTMENT" "$SINK" toggle
|
|
||||||
else
|
|
||||||
set_level "$ADJUSTMENT"
|
set_level "$ADJUSTMENT"
|
||||||
limit_level $LIMIT
|
limit_level "$VOLUME_LIMIT"
|
||||||
|
elif [[ "$TARGET" == "toggle" ]]; then
|
||||||
|
amixer -D pulse sset "$ADJUSTMENT" toggle
|
||||||
|
else
|
||||||
|
echo "Invalid option: $TARGET $ADJUSTMENT"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
killall -SIGUSR1 i3status
|
killall -SIGUSR1 i3status
|
||||||
|
|
Loading…
Reference in New Issue