Skip to content

Instantly share code, notes, and snippets.

@joel-wright
Created January 9, 2017 23:26
Show Gist options
  • Save joel-wright/68fc3031cbb3f7cd25db1ed2fe656e60 to your computer and use it in GitHub Desktop.
Save joel-wright/68fc3031cbb3f7cd25db1ed2fe656e60 to your computer and use it in GitHub Desktop.
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