Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AW13 OLED Monitor Brightness
#!/bin/sh
path=/sys/class/backlight/intel_backlight
luminance() {
read -r level < "$path"/actual_brightness
factor=$((max / 100))
ret=`printf '%d\n' "$((level / factor))"`
if [ $ret -gt 100 ]; then
ret=100
fi
printf `echo "$ret / 100" | bc -l`
}
read -r max < "$path"/max_brightness
while inotifywait -e modify "$path"/actual_brightness; do
lm=$(luminance)
echo -n "${lm}" > ~/.brightness
xrandr --output eDP-1 --brightness "${lm}"
# If the previous command failed it's because the nvidia
# card is active and it reports different display names
if [ $? -gt 0 ]
then
xrandr --output eDP-1-1 --brightness "${lm}"
fi
done
@indivisible
Copy link

Thanks a lot for this! I've ran into the problem that some events and applications reset the brightness value, so I made an alternate version:
https://gist.github.com/indivisible/f643d970bbe362ab1d5cf7c4e604c984

@moutasem1989
Copy link

sadly Xrandr is not supported on Chromium OS ! any alternatives in sight ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment