You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
3 years ago
|
#!/bin/bash
|
||
|
|
||
|
function volumedelta() {
|
||
|
local CURRENT_VOLUME=$( pacmd list-sinks | grep -A 15 '* index' | awk '/volume: front/{ print $5 }' | sed 's/[%|,]//g')
|
||
|
local NEW_VOLUME=$(( $CURRENT_VOLUME + $1 ))
|
||
|
local NEW_VOLUME=$(( $NEW_VOLUME > 100 ? 100 : $NEW_VOLUME ))
|
||
|
local NEW_VOLUME=$(( $NEW_VOLUME < 0 ? 0 : $NEW_VOLUME ))
|
||
|
pactl set-sink-volume '@DEFAULT_SINK@' "${NEW_VOLUME}%"
|
||
|
}
|
||
|
case $1 in
|
||
|
up)
|
||
|
volumedelta 10
|
||
|
pactl set-sink-mute '@DEFAULT_SINK@' 0
|
||
|
;;
|
||
|
down)
|
||
|
volumedelta -10
|
||
|
;;
|
||
|
off)
|
||
|
volumedelta -9999
|
||
|
;;
|
||
|
max)
|
||
|
volumedelta 9999
|
||
|
pactl set-sink-mute '@DEFAULT_SINK@' 0
|
||
|
;;
|
||
|
toggle_mute)
|
||
|
pactl set-sink-mute '@DEFAULT_SINK@' toggle
|
||
|
;;
|
||
|
full_mute)
|
||
|
pactl set-sink-mute '@DEFAULT_SINK@' 1
|
||
|
pactl set-sink-volume '@DEFAULT_SINK@' 0
|
||
|
;;
|
||
|
esac
|
||
|
pkill -SIGUSR1 i3status
|
||
|
VOLUME=$( pacmd list-sinks | grep -A 15 '* index' | awk '/volume: front/{ print $5 }' | sed 's/[%|,]//g' )
|
||
|
MUTED=$( pacmd list-sinks | grep -A 15 '* index' | awk '/muted:/{ print $2 }' | grep -m1 yes )
|
||
|
ID_LOCATION=/run/user/$(id -u)/i3-helpers/volume-notification-id
|
||
|
OLD_ID=$(<"$ID_LOCATION")
|
||
|
NEW_ID=$(dunstify --appname=brightness.sh --timeout=3000 --hints="int:value:$VOLUME" --printid "${OLD_ID:+--replace="${OLD_ID}"}" "Volume" "${VOLUME}%${MUTED:+ (Muted)}" )
|
||
|
mkdir -p $(dirname "$ID_LOCATION")
|
||
|
echo "$NEW_ID" >"$ID_LOCATION"
|