nixdots/home/programs/graphical/wms/hyprland/packages/brightness/brightness.sh

23 lines
744 B
Bash
Raw Normal View History

2024-06-10 12:32:51 +00:00
#!/bin/sh
2024-06-10 13:11:49 +00:00
# This is mainly a wrapper, acting as just: `brightnessctl s $1`
# However, in addition, this will also produce a notification with
# the brightness level shown as a progress bar.
2024-06-10 12:32:51 +00:00
# Send brightness level desktop notification, showing the given brightness level
# as progress bar, along with given message.
# $1 - brightness level (number 0-100)
send_brightness_notify() {
percent_brightness="$1"
notify-send \
2024-06-10 13:11:49 +00:00
--app-name="brightness" \
--urgency="normal" \
2024-06-10 12:32:51 +00:00
-h int:value:$percent_brightness \
-h string:synchronous:brightness \
2024-06-10 13:11:49 +00:00
"brightness" "Level: $percent_brightness"
2024-06-10 12:32:51 +00:00
}
2024-06-10 13:11:49 +00:00
out="$(brightnessctl s "$1")"
cur_percent="$(echo "$out" | grep "Current" | grep -oP '\(\d+%' | tr -d '()%')"
send_brightness_notify "$cur_percent"