From 5e39801d920012594a0fb63ac1ccd41acc3d80ec Mon Sep 17 00:00:00 2001 From: esche Date: Sun, 10 Dec 2023 20:46:48 +0100 Subject: [PATCH] Notifications for audio and brightness --- .config/sway/notify.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .config/sway/notify.sh diff --git a/.config/sway/notify.sh b/.config/sway/notify.sh new file mode 100644 index 0000000..1361f3c --- /dev/null +++ b/.config/sway/notify.sh @@ -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