1
0
Fork 0
dotfiles/.local/bin/brightness-notify

33 lines
864 B
Bash
Executable File

#!/bin/sh
calc() {
awk "BEGIN {print int($*)}"
}
msgTag="brightness" # Arbitrary but unique message tag
oldbrightness="$(cat /sys/class/backlight/*/brightness)"
newbrightness="$(calc "$oldbrightness + $1 * 2.55")"
percentage=$(calc "$newbrightness * .39215686274509803921")
highlight="#7aa2f7"
if [ "$percentage" -gt "100" ]; then
icon="gpm-brightness-lcd"
percentage=100
newbrightness=255
elif [ "$percentage" -gt "50" ]; then
icon="gpm-brightness-lcd"
elif [ "$percentage" -gt "0" ]; then
icon="gpm-brightness-lcd-disabled"
else
icon="gpm-brightness-lcd-disabled"
percentage=0
newbrightness=0
fi
echo $newbrightness | tee /sys/class/backlight/*/brightness
notify-send -a "changeBrightness" -i "$icon" -u low "Brightness: ${percentage}%" \
-h string:x-dunst-stack-tag:$msgTag \
-h int:value:$percentage \
-h string:hlcolor:$highlight