2023-03-28 18:46:39 +02:00
|
|
|
#!/bin/sh
|
2023-04-12 11:29:00 +02:00
|
|
|
msgTag="brightness" # Arbitrary but unique message tag
|
|
|
|
highlight="#7aa2f7"
|
2023-03-28 18:46:39 +02:00
|
|
|
|
2023-04-12 11:29:00 +02:00
|
|
|
round() {
|
2023-04-12 11:37:10 +02:00
|
|
|
awk "BEGIN {printf \"%.0f\", $*}"
|
2023-03-28 18:46:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
oldbrightness="$(cat /sys/class/backlight/*/brightness)"
|
2023-04-12 11:29:00 +02:00
|
|
|
oldpercent="$(round "$oldbrightness * (100/255)")"
|
|
|
|
newpercent="$(round "$oldpercent + $1")"
|
|
|
|
newbrightness="$(round "$newpercent * (255/100)")"
|
2023-03-28 18:46:39 +02:00
|
|
|
|
2023-04-12 11:29:00 +02:00
|
|
|
if [ "$newpercent" -gt "100" ]; then
|
2023-04-12 11:37:10 +02:00
|
|
|
icon="gpm-brightness-lcd"
|
|
|
|
newpercent=100
|
|
|
|
newbrightness=255
|
2023-04-12 11:29:00 +02:00
|
|
|
elif [ "$newpercent" -gt "50" ]; then
|
2023-04-12 11:37:10 +02:00
|
|
|
icon="gpm-brightness-lcd"
|
2023-04-12 11:29:00 +02:00
|
|
|
elif [ "$newpercent" -gt "0" ]; then
|
2023-04-12 11:37:10 +02:00
|
|
|
icon="gpm-brightness-lcd-disabled"
|
2023-03-28 18:46:39 +02:00
|
|
|
else
|
2023-04-12 11:37:10 +02:00
|
|
|
icon="gpm-brightness-lcd-disabled"
|
|
|
|
newpercent=0
|
|
|
|
newbrightness=0
|
2023-03-28 18:46:39 +02:00
|
|
|
fi
|
|
|
|
|
2023-04-12 11:29:00 +02:00
|
|
|
round $newbrightness | tee /sys/class/backlight/*/brightness
|
2023-03-28 18:46:39 +02:00
|
|
|
|
2023-04-12 11:29:00 +02:00
|
|
|
notify-send -a "changeBrightness" -i "$icon" -u low "Brightness: ${newpercent}%" \
|
2023-04-12 11:37:10 +02:00
|
|
|
-h string:x-dunst-stack-tag:$msgTag \
|
|
|
|
-h int:value:$newpercent \
|
|
|
|
-h string:hlcolor:$highlight
|