An even better script so that all connected displays have their
brightness adjusted


#!/bin/bash
#-----------------------------------------------------------------
# /usr/local/bin/brightness
# be sure this file is executable
#-----------------------------------------------------------------

backlight_path=/sys/class/backlight/intel_backlight

luminance() {
    read -r level < "$backlight_path"/actual_brightness
    bc <<< "scale=10;$level/$max"
}

devices() {
    xrandr | grep -w connected | awk '{ print $1 }'
}

apply() {
    for device in $(devices)
    do
        echo "$device" "$1"
        xrandr --output "$device" --brightness "$1"
    done    
}

read -r max < "$backlight_path"/max_brightness
apply "$(luminance)"

inotifywait -me modify --format '' "$backlight_path"/actual_brightness | while 
read; do
    apply "$(luminance)"
done

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1831587

Title:
  brightness control not work with OLED panel

Status in HWE Next:
  New
Status in OEM Priority Project:
  New
Status in linux package in Ubuntu:
  Triaged

Bug description:
  image: disco 19.04
  kernel: 5.0.0-15-generic
  also verified failed on linux-image-unsigned-5.2.0-050200rc2-generic

  also refer to :
   - 
https://askubuntu.com/questions/824949/lenovo-thinkpad-x1-yoga-oled-brightness
   - https://bugs.freedesktop.org/show_bug.cgi?id=97883

  Linux can not control the brightness on the OLED panel in the traditional way 
[1].
  Although there's a workaround from the community [2] that to execute script 
while brightness hotkey event is triggered. But if we want to upstream it, it's 
still a problem to recognize the OLED panel so that the system knows when to go 
workaround.
   - EDID of my laptop which has OLED: https://paste.ubuntu.com/p/w7rVqJTYDy/
   - EDID of the same model without OLED: https://paste.ubuntu.com/p/P3ChhX9yBJ/

  there's a kernel patch related OLED for reference:
   - https://patchwork.kernel.org/patch/6133471/

  [1] https://wiki.ubuntu.com/Kernel/Debugging/Backlight
  [2] 
https://askubuntu.com/questions/824949/lenovo-thinkpad-x1-yoga-oled-brightness

To manage notifications about this bug go to:
https://bugs.launchpad.net/hwe-next/+bug/1831587/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to