When using multiple monitors, and disconnecting and reconnecting them, I noticed that Ubuntu 20.04 likes to set the external monitor's brightness to 0.06, and the laptop's brightness to maximum. This is done without changing the file at (/sys/class/backlight/intel_backlight/actual_brightness).
I have modified the above script to work with multiple monitors, and to change the brightness whenever a discrepancy between the desired and actual brightnesses of all monitors is detected. The script assumes that the internal laptop monitor's brightness is the only one to be changed by brightness keys, and that the laptop's monitor is the first monitor listed in the command `xrandr --listmonitors`. Please reply if you have any issues with this script, as I do want to improve this. #!/bin/bash #----------------------------------------------------------------- # /usr/local/bin/brightness # be sure this file is executable #----------------------------------------------------------------- # Define a function which finds luminance values in default Ubuntu # location, converts into a factor of maximum brightness # Get the max brightness for reference. # Get it to 2 decimal places backlight_path=/sys/class/backlight/intel_backlight read -r max < "$backlight_path"/max_brightness luminance() { read -r level < "$backlight_path"/actual_brightness printf "%.2f" $(bc <<< "scale=10;$level/$max") } # Set up infinite loop while true do # Get the current brightness levels from xrandr. Store in array mapfile \ -t xrandrbrightness \ < <(xrandr --verbose --current \ | grep Brightness \ | sed 's/.* //' \ | xargs printf "%.2f\n") # Get list of monitors and store in array mapfile \ -t monitors \ < <(xrandr --listmonitors --current \ | grep -v 'Monitors' \ | awk '{print $4}') # If the current brightness for monitor 0 != the desired value +/-0.01 if (( $(echo "${xrandrbrightness[0]} != $(luminance)" | bc -l) )) then # Set the brightness of the laptop monitor to the desired value echo "${monitors[0]} Current:${xrandrbrightness[0]} Desired:$(luminance)" xrandr --output "${monitors[0]}" --brightness "$(luminance)" fi # Go through the rest of the monitors in the list for (( i=1; i<${#monitors[@]}; i++ )) do # Change the brightness of external monitors to 1 if they aren't if (( $(echo "${xrandrbrightness[$i]} != 1.00" | bc -l) )) then echo "${monitors[$i]} Current:${xrandrbrightness[$i]}" xrandr --output "${monitors[$i]}" --brightness 1 fi done # Check every 100ms sleep 0.1 done -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1831587 Title: brightness control not work with OLED panel To manage notifications about this bug go to: https://bugs.launchpad.net/hwe-next/+bug/1831587/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs