41 lines
1.4 KiB
Bash
41 lines
1.4 KiB
Bash
|
#!/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
|