From c56fc16b7d6bbd5e1a6aa1bb030c17d1752ff166 Mon Sep 17 00:00:00 2001 From: Luc Bijl Date: Thu, 14 Aug 2025 20:34:21 +0000 Subject: [PATCH] src/brightness: add --- src/brightness | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 src/brightness diff --git a/src/brightness b/src/brightness new file mode 100755 index 0000000..9e1d497 --- /dev/null +++ b/src/brightness @@ -0,0 +1,26 @@ +#!/bin/sh + +# Define icon theme and path +icon_theme="Tela-circle-black-dark" +icon_path="/usr/share/icons/${icon_theme}/24/panel" + +# Define icon file +brightness_lcd="${icon_path}/gpm-brightness-lcd.svg" + +# Loop through each backlight +for backlight_path in /sys/class/backlight/*; do + # Extract backlight from path + backlight="${backlight_path##*/}" + + # Read the last brightness notification ID from state, or set default if it does not exist. + last_notify_id="$(cat "$HOME/.local/state/brightness/$backlight" || echo "1024")" + + # Get the brightness percentage of the backlight + brightness="$(( 100 * $(cat "$backlight_path/brightness") / $(cat "$backlight_path/max_brightness") ))" + + # Send the brightness notification + last_notify_id="$(notify-send "Brightness ${brightness}%" -h int:value:$brightness -h string:synchronous: -i $brightness_lcd -t 2000 -r $last_notify_id -p)" + + # Write the last brightness notification ID to state + echo "$last_notify_id" > "$HOME/.local/state/brightness/$backlight" +done