Ok I could not wait more… so I now have a fairly complete workaround:
I use scripts in the “other settings” section to trigger the brightness adjustment.
The script will read the required brightness value from .config/powerdevilrc
and use qdbus6
to set the value.
It works for all 3 modes: AC, Battery and LowBattery.
The script is executed when the energy mode changes (un/plug AC cord) but also when clicking “Apply” on the system settings.
Here is the common script, named brightness-powerdevil.sh
, to be saved somewhere accessible from your PATH, for instance $HOME/bin
, and made executable with
chmod 755 brightness-powerdevil.sh
#!/bin/bash
# This script can be used to replace the default behaviour of KDE powerdevil
# brightness management, until it is fixed upstream.
# It should be called with parameter "AC" or "Battery" or "LowBattery".
#
# sanette 2024
# https://discuss.kde.org/t/automatic-screen-brightness-stopped-working-after-neon-6-2-install/23915
energy=$1
# We use a log file for debugging
echo $(date) >> /tmp/brightness.log
echo " Energy=$energy" >> /tmp/brightness.log
# We extract the required value (percentage) from KDE energy system
# settings (powerdevilrc)
sed_exp="sed -n '/^\["$energy"\]\[Display\]/, /^$/p' $HOME/.config/powerdevilrc | sed -n 's/^DisplayBrightness=\([0-9]\+\)/\1/p'"
value=$(eval $sed_exp)
# We get brightnessMax (for me this is 10000)
kdeMax=$(qdbus6 local.org_kde_powerdevil /org/kde/Solid/PowerManagement/Actions/BrightnessControl brightnessMax)
# We convert the percentage value into a correct brightness value
brightness=$(( $value * $kdeMax / 100 ))
# Sleep is not necessary, but it will help noticing when the issue has
# been fixed upstream
sleep 1
echo " value=$value, Max=$kdeMax, brightness=$brightness" >> /tmp/brightness.log
# We set the new brightness. The advantage compared to directly
# accessing /sys/class/backlight/intel_backlight/brightness is that
# this should work (with KDE) without sudo
qdbus6 local.org_kde_powerdevil /org/kde/Solid/PowerManagement/Actions/BrightnessControl setBrightness $brightness
# One could also use setBrightnessSilent to suppress onscreen notification
Then in the “other settings” of the Energy settings panel, enter the name of the following scripts: brightness-ac.sh
, brightness-battery.sh
, and brightness-lowbattery.sh
in the correspondig tabs (don’t forget chmod 755
)
$ more brightness-ac.sh
#!/bin/bash
# This script can be used to replace the default behaviour of KDE powerdevil
# brightness management, until it is fixed upstream.
# It should be called when AC power is plugged in: see the Energy system settings.
#
# sanette 2024
# https://discuss.kde.org/t/automatic-screen-brightness-stopped-working-after-neon-6-2-install/23
915
brightness-powerdevil.sh AC
$ more brightness-battery.sh
#!/bin/bash
# This script can be used to replace the default behaviour of KDE
# powerdevil brightness management, until it is fixed upstream. It
# should be called when entering Battery mode (AC power is unplugged):
# see the Energy system settings.
#
# sanette 2024
# https://discuss.kde.org/t/automatic-screen-brightness-stopped-working-after-neon-6-2-install/23
915
brightness-powerdevil.sh Battery
$ more brightness-lowbattery.sh
#!/bin/bash
# This script can be used to replace the default behaviour of KDE powerdevil
# brightness management, until it is fixed upstream.
# It should be called when entering Low Battery Mode: see the Energy system settings.
#
# sanette 2024
# https://discuss.kde.org/t/automatic-screen-brightness-stopped-working-after-neon-6-2-install/23
915
brightness-powerdevil.sh LowBattery