1

I want to change brightness of my monitor via the /sys/class/backlight/radeon_bl0/brightness file. But the file has -rw-r--r--. permissions, so only root can write to it. This article says, that I can configure a udev rule for changing the permissions. It doesn't work. I have little bit modified the rule, to match my computer. My graphiphics card is radeon_b10, not acpi_video0 .

ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="radeon_b10", RUN+="/usr/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="radeon_b10", RUN+="/usr/bin/chmod g+w /sys/class/backlight/%k/brightness"

I have tried everything. Monitoring the rules using $ udevadm monitor and triggering the rules using # udevadm trigger --action=add /sys/class/backlight/radeon_bl0. The rules are fired, but the file /sys/class/backlight/%k/brightness is still:

-rw-r--r--. 1 root root 4096 Aug  1 16:09 brightness

(output from $ ll -a /sys/class/backlight/radeon_bl0/)

Why udev doesn't execute the RUN statement?

Info about my system:

[marian@bagr ~]$ uname -a
Linux bagr 4.17.9-200.fc28.x86_64 #1 SMP Mon Jul 23 21:41:29 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[marian@bagr ~]$ ll -a /sys/class/backlight/radeon_bl0/
total 0
drwxr-xr-x. 3 root root    0 Aug  1  2018 .
drwxr-xr-x. 6 root root    0 Aug  1  2018 ..
-r--r--r--. 1 root root 4096 Aug  1 16:09 actual_brightness
-rw-r--r--. 1 root root 4096 Aug  1 16:09 bl_power
-rw-r--r--. 1 root root 4096 Aug  1 16:09 brightness
lrwxrwxrwx. 1 root root    0 Aug  1 16:09 device -> ../../card0-eDP-1
-r--r--r--. 1 root root 4096 Aug  1 16:09 max_brightness
drwxr-xr-x. 2 root root    0 Aug  1 16:09 power
lrwxrwxrwx. 1 root root    0 Aug  1  2018 subsystem -> ../../../../../../../class/backlight
-r--r--r--. 1 root root 4096 Aug  1 16:09 type
-rw-r--r--. 1 root root 4096 Aug  1 16:09 uevent
[marian@bagr ~]$ udevadm info -q all -a /sys/class/backlight/radeon_bl0
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:01.0/drm/card0/card0-eDP-1/radeon_bl0':
    KERNEL=="radeon_bl0"
    SUBSYSTEM=="backlight"
    DRIVER==""
    ATTR{actual_brightness}=="30"
    ATTR{bl_power}=="0"
    ATTR{brightness}=="30"
    ATTR{max_brightness}=="255"
    ATTR{type}=="raw"

  looking at parent device '/devices/pci0000:00/0000:00:01.0/drm/card0/card0-eDP-1':
    KERNELS=="card0-eDP-1"
    SUBSYSTEMS=="drm"
    DRIVERS==""
    ATTRS{dpms}=="On"
    ATTRS{edid}==""
    ATTRS{enabled}=="enabled"
    ATTRS{status}=="connected"

  looking at parent device '/devices/pci0000:00/0000:00:01.0/drm/card0':
    KERNELS=="card0"
    SUBSYSTEMS=="drm"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:01.0':
    KERNELS=="0000:00:01.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="radeon"
    ATTRS{ari_enabled}=="0"
    ATTRS{boot_vga}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x030000"
    ATTRS{consistent_dma_mask_bits}=="40"
    ATTRS{current_link_speed}=="Unknown speed"
    ATTRS{current_link_width}=="0"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x9850"
    ATTRS{dma_mask_bits}=="40"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="35"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{local_cpus}=="f"
    ATTRS{max_link_speed}=="Unknown speed"
    ATTRS{max_link_width}=="255"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{power_dpm_force_performance_level}=="auto"
    ATTRS{power_dpm_state}=="balanced"
    ATTRS{power_method}=="dpm"
    ATTRS{power_profile}=="default"
    ATTRS{revision}=="0x40"
    ATTRS{subsystem_device}=="0x81f5"
    ATTRS{subsystem_vendor}=="0x103c"
    ATTRS{vendor}=="0x1002"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
3
  • sysfs doesn't actually support changing permissions. Aug 3, 2018 at 17:16
  • oh, really? sad.. Is there any way how to get this working? Why udev rules have GROUP, OWNER and MODE? What about creating a symlink? Aug 4, 2018 at 18:12
  • Because udev affects things under /dev, which is essentially always on a filesystem that supports changing permissions. Aug 4, 2018 at 19:49

2 Answers 2

0

One possible reason is that the file to be changed does not yet exist.

Run a script instead of chown and chmod that can examine whether the target exists and can write information to a log file.

2
  • Now I have ACTION=="add", SUBSYSTEM=="basklight", KERNEL=="radeon_b10", RUN+="/home/marian/bin/udevcheck.sh" in my rule. The script is tree -l -L 2 /sys/class/backlight/ > /home/marian/bin/udevcheck.log. It is marked a executable and has a shebang. The file udevcheck.log doesn't exist. Aug 2, 2018 at 11:20
  • Oh, I had a typo in my test rule, but it still doesn't work... Aug 2, 2018 at 14:45
0

I've used the change action instead of the add and everything works:

ACTION=="change", SUBSYSTEM=="backlight", KERNEL=="radeon_b10", RUN+="/usr/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="change", SUBSYSTEM=="backlight", KERNEL=="radeon_b10", RUN+="/usr/bin/chmod g+w /sys/class/backlight/%k/brightness"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .