Cannot control brightness(Wayland)

Hi there,

I want to change the brightness of my built in screen. I am using Wayland, before installing it I had xorg and wrote a script with xrandr to dec/inc brightness with keys. But when I changed to Wayland it clearly wont work that way. I am now unable to control the brightness. First I tried the scroll thing in battery icon, but it tried to change the brightness of external monitor(probably because its the primary one). I tried gammastep and it gave this error

error: XDG_RUNTIME_DIR is invalid or not set in the environment.
Error: Could not connect to wayland display, exiting.
Error: Failed to start adjustment method: wayland

I also tried brightnessctl, but all the device brightnesses were at 0%, which is strange.

Available devices:
Device 'nvidia_wmi_ec_backlight' of class 'backlight':
        Current brightness: 0 (-2147483648%)
        Max brightness: 0

Device 'input24::compose' of class 'leds':
        Current brightness: 0 (0%)
        Max brightness: 1

Device 'input4::capslock' of class 'leds':
        Current brightness: 0 (0%)
        Max brightness: 1

Device 'input24::capslock' of class 'leds':
        Current brightness: 0 (0%)
        Max brightness: 1

Device 'input4::scrolllock' of class 'leds':
        Current brightness: 0 (0%)
        Max brightness: 1

Device 'input4::numlock' of class 'leds':
        Current brightness: 1 (100%)
        Max brightness: 1

Device 'input24::numlock' of class 'leds':
        Current brightness: 1 (100%)
        Max brightness: 1

Device 'rtl8xxxu-usb3-2' of class 'leds':
        Current brightness: 2 (100%)
        Max brightness: 2

Device 'input24::kana' of class 'leds':
        Current brightness: 0 (0%)
        Max brightness: 1

Device 'input24::scrolllock' of class 'leds':
        Current brightness: 0 (0%)
        Max brightness: 1

Device 'mmc0::' of class 'leds':
        Current brightness: 0 (0%)
        Max brightness: 255

I also tried

sudo echo 20 > /sys/class/backlight/nvidia_wmi_ec_backlight/brightness 

I got permission denied, also in the file, the brightness and max-brightness were 0.

Does anybody know how to solve this?

Here is info:

System:
  Kernel: 6.5.9-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 13.2.1
    Desktop: KDE Plasma v: 5.27.9 Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: LENOVO product: 82UX v: Lenovo Slim 7 16ARH7
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: SDK0T76530 WIN
    serial: <superuser required> UEFI: LENOVO v: KLCN19WW date: 06/08/2023
Battery:
  ID-1: BAT0 charge: 52.4 Wh (78.7%) condition: 66.6/75.0 Wh (88.8%)
    volts: 15.8 min: 15.4 model: LENOVO AP16L5J status: not charging
CPU:
  Info: 8-core model: AMD Ryzen 7 6800HS Creator Edition bits: 64 type: MT MCP
    arch: Zen 3+ rev: 1 cache: L1: 512 KiB L2: 4 MiB L3: 16 MiB
  Speed (MHz): avg: 778 high: 2068 min/max: 400/4785 cores: 1: 1467 2: 400
    3: 400 4: 400 5: 2068 6: 400 7: 400 8: 400 9: 400 10: 400 11: 1397 12: 1732
    13: 400 14: 400 15: 1396 16: 400 bogomips: 102267
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Graphics:
  Device-1: NVIDIA GA107BM [GeForce RTX 3050 Mobile] vendor: Lenovo
    driver: nvidia v: 535.129.03 arch: Ampere bus-ID: 01:00.0
  Device-2: AMD Rembrandt [Radeon 680M] vendor: Lenovo driver: amdgpu
    v: kernel arch: RDNA-2 bus-ID: 05:00.0 temp: 39.0 C
  Device-3: IMC Networks [] driver: uvcvideo type: USB bus-ID: 5-1:2
  Display: wayland server: X.org v: 1.21.1.9 with: Xwayland v: 23.2.2
    compositor: kwin_wayland driver: X: loaded: amdgpu,nvidia
    unloaded: modesetting,nouveau dri: radeonsi gpu: nvidia,amdgpu resolution:
    1: 1920x1080 2: 1707x1067
  API: EGL v: 1.5 drivers: nvidia,radeonsi,swrast platforms:
    active: wayland,x11,surfaceless,device inactive: gbm,device-2
  API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: amd mesa v: 23.1.9-manjaro1.1
    glx-v: 1.4 direct-render: yes renderer: AMD Radeon Graphics (rembrandt LLVM
    16.0.6 DRM 3.54 6.5.9-1-MANJARO)
  API: Vulkan v: 1.3.269 drivers: nvidia,radv surfaces: xcb,xlib,wayland
    devices: 2
Audio:
  Device-1: AMD Rembrandt Radeon High Definition Audio vendor: Lenovo
    driver: snd_hda_intel v: kernel bus-ID: 05:00.1
  Device-2: AMD ACP/ACP3X/ACP6x Audio Coprocessor vendor: Lenovo
    driver: snd_pci_acp6x v: kernel bus-ID: 05:00.5
  Device-3: AMD Family 17h/19h HD Audio vendor: Lenovo driver: snd_hda_intel
    v: kernel bus-ID: 05:00.6
  API: ALSA v: k6.5.9-1-MANJARO status: kernel-api
  Server-1: JACK v: 1.9.22 status: off
  Server-2: PipeWire v: 0.3.83 status: off
  Server-3: PulseAudio v: 16.1 status: active
Network:
  Device-1: Realtek vendor: Lenovo driver: rtw89_8852be v: kernel port: 2000
    bus-ID: 02:00.0
  IF: wlp2s0 state: down mac: <filter>
  Device-2: KYE Systems (Mouse Systems) GF3000F Ethernet Adapter
    driver: hid-generic,usbhid type: USB bus-ID: 3-1:2
Bluetooth:
  Device-1: Realtek [] driver: btusb v: 0.8 type: USB bus-ID: 3-3:3
  Report: rfkill ID: hci0 rfk-id: 2 state: up address: see --recommends
Drives:
  Local Storage: total: 931.51 GiB used: 100.81 GiB (10.8%)
  ID-1: /dev/nvme0n1 vendor: Western Digital model: WD BLACK SN850X 1000GB
    size: 931.51 GiB temp: 36.9 C
Partition:
  ID-1: / size: 577.2 GiB used: 100.75 GiB (17.5%) fs: ext4
    dev: /dev/nvme0n1p5
  ID-2: /boot/efi size: 256 MiB used: 67.5 MiB (26.4%) fs: vfat
    dev: /dev/nvme0n1p1
Swap:
  Alert: No swap data was found.
Sensors:
  System Temperatures: cpu: 51.6 C mobo: N/A gpu: amdgpu temp: 43.0 C
  Fan Speeds (rpm): N/A
Info:
  Processes: 377 Uptime: 54m Memory: total: 16 GiB note: est.
  available: 13.34 GiB used: 5.11 GiB (38.3%) Init: systemd Compilers:
  gcc: 13.2.1 clang: 16.0.6 Packages: 1424 Shell: Zsh v: 5.9 inxi: 3.3.31

thank you:)

To control backlight on wayland, any newer system you need acpilight

  1. install acpilight
    sudo pacman -Syu acpilight
    
  2. Add your user to the video group
    sudo gpasswd -a $USER video
    
  3. start the acpid
    sudo systemctl enable --now acpid
    

Logout and login to apply the group membership

1 Like

Thank you for your reply, should I be able to control it with xbacklight?

if yes it gives an error

xbacklight -set 50                                                                                                                                                                                                         1 ✘ 
Traceback (most recent call last):
  File "/usr/bin/xbacklight", line 200, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/bin/xbacklight", line 180, in main
    current = ctrl.brightness
              ^^^^^^^^^^^^^^^
  File "/usr/bin/xbacklight", line 65, in brightness
    return super().brightness*100/super().max_brightness
           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: division by zero

I guess its because max-brightness is 0 or cant find max?

xbacklight doesn’t work for newer gpu’s and or wayland.

the script for controlling acpilight is called xbacklight for compatibility reasons.

man xbacklight

you can get a list of what can be controlled

xbacklight -list

Sorry, I don’t completely understand. So after the steps in your first reply I should have been able to change the brightness like this

sudo echo 20 > /sys/class/backlight/nvidia_wmi_ec_backlight/brightness

right?

Or if not how else do I need to change it? I think I mixed everything I read about this issue, sorry.

I have no idea - apparently you try to control an nvidia card - and I don’t have a laptop with nvidia - so I cannot say.

I would list the content of backlight sys folder to get an idea what is avaiable

ls /sys/class/backlight

Other than that I cannot tell you what to do …

1 Like

Thank you for your replies and for trying to help:)

ls /sys/class/backlight                                                                                                                                                                                                   
nvidia_wmi_ec_backlight

The issue is that the values of max_brightness, brightness, and actual_brightness are 0 so I think that’s causing the gammastep, brightnessctl to fail. I don’t really know how to move forward from this point. Is there someone with similar issue with Nvidia gpu?

Did you check the Arch wiki for Nvidia cards?

https://wiki.archlinux.org/title/NVIDIA/Troubleshooting

Thank you, I just did. Unfortunately, I could not find this problem there, however, I found some other problems I was experiencing.

A quick search tells me you are not the only one with the issue

https://sx.nix.dk/search?q=linux nvidia_wmi_ec_backlight is always 0

From just scanning the search page it could be a kernel argument that is need to activate brightness.

1 Like

Wait, does this screen (your monitor) have its own setting for the brightness, which is independent of Nvidia control?

In my experience, KDE Wayland works well with native controlling the brightness of my monitor by default, not GPU control.
I don’t need to install any additional program manually.

Screenshot_20231112_092710

1 Like

You can’t sudo echo to a privileged file like that.

I use the sudo sh -c method;

sudo sh -c "echo 20 > /sys/class/backlight/nvidia_wmi_ec_backlight/brightness"
1 Like

My acer laptop iGPU had the same issue and the only fix was to add a kernel parameter in

/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet udev.log_priority=3 acpi_backlight=native"

See Backlight - ArchWiki

2 Likes

In my case changing the display brightness with the scroll does nothing, unfortunately. Nothing I do changes the brightness:( I think my monitor should have its own setting for the brightness, it also had some problems with xorg but at least I could change it with xrandr.

Thank you all for your replies:) I have added a kernel parameter acpi_backlight=native like medmedin said and then did

sudo sh -c "echo 20 > /sys/class/backlight/amdgpu_bl1/brightness" 

as MrLavander suggested. This time it worked!

Thanks again

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.