Created
December 15, 2019 19:15
-
-
Save reilg/d60dec0d2174310b3dd5837f540ac56b to your computer and use it in GitHub Desktop.
XPS 15 7590 - Backlight Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#use LC_NUMERIC if you are using an European LC, else printf will not work because it expects an comma instead of a decimal point | |
LC_NUMERIC="en_US.UTF-8" | |
#Exit with 1 if $DISPLAY env isn't set. Helps when using the start up script below | |
[ -z "$DISPLAY" ] && exit 1; | |
# modify this path to the location of your backlight class | |
path=/sys/class/backlight/intel_backlight | |
read -r max < "$path"/max_brightness | |
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` | |
} | |
# support both intel and nvidia | |
DEVICE=eDP-1 | |
if [ ! -z "$(xrandr -q --output $DEVICE 2>&1)" ]; then | |
DEVICE=eDP-1-1 | |
fi | |
xrandr --output $DEVICE --brightness "$(luminance)" | |
inotifywait -me modify --format '' "$path"/actual_brightness | while read; do | |
xrandr --output $DEVICE --brightness "$(luminance)" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment