Notifications for audio and brightness

This commit is contained in:
esche 2023-12-10 20:46:48 +01:00
parent 7abb42aaf2
commit 5e39801d92

40
.config/sway/notify.sh Normal file
View file

@ -0,0 +1,40 @@
#!/bin/bash
notify_volume() {
volume_inf=$(wpctl get-volume $1)
volume=$(echo $volume_inf | awk '{print $2*100}')
if [[ $volume -eq 0 ]]; then icon=audio-volume-muted
elif [[ $volume -lt 30 ]]; then icon=audio-volume-low
elif [[ $volume -lt 60 ]]; then icon=audio-volume-medium
else icon=audio-volume-high
fi
notify-send -h int:value:$volume -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "$volume_inf" -c "status"
}
notify_mute() {
status=($(wpctl get-volume $1 |
awk '{
print $3=="[MUTED]" ? "OFF audio-volume-muted":"ON audio-volume-medium";
}'))
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i ${status[1]} "Volume switched ${status[0]}" -c "status"
}
notify_brightness() {
brightness=$(brightnessctl | grep -Eo '([[:digit:]]+%)')
notify-send -h int:value:${brightness%?} -h string:x-canonical-private-synchronous:sys-notify -u low -i brightnesssettings "Brightness: $brightness" -c "status"
}
# Execute accordingly
if [[ "$1" == "--audio" ]]; then
notify_volume "@DEFAULT_SINK@"
elif [[ "$1" == "--mic" ]]; then
notify_volume "@DEFAULT_SOURCE@"
elif [[ "$1" == "--mic-mute" ]]; then
notify_mute "@DEFAULT_SOURCE@"
elif [[ "$1" == "--audio-mute" ]]; then
notify_mute "@DEFAULT_SINK@"
elif [[ "$1" == "--brightness" ]]; then
notify_brightness "@DEFAULT_SINK@"
fi