3

I'm trying to let my user bob the permissions to change the screen brightness, which means: let bob read, write permissions for /sys/class/backlight/intel_backlight/brightness

using:

udevadm info -a -p /sys/class/backlight/intel_backlight/

shows that following result:

  looking at device '/devices/pci0000:00/0000:00:02.0/drm/card1/card1-eDP-1/intel_backlight':
KERNEL=="intel_backlight"
SUBSYSTEM=="backlight"
DRIVER==""
ATTR{actual_brightness}=="7500"
ATTR{bl_power}=="0"
ATTR{brightness}=="7500"
ATTR{max_brightness}=="7500"
ATTR{type}=="raw"

.
.
.

So I wrote a udev rule for that in /etc/udev/rules.d/30-brightness.rules

30-brightness.rules

KERNEL=="intel_backlight", SUBSYSTEM=="backlight", RUN+="/usr/bin/find /sys/class/backlight/intel_backlight/ -type f -name brightness -exec chown bob:bob {} \; -exec chmod 666 {} \;"

But event after a reboot the file permissions stays -rw-r--r-- 1 root root

So my question is how to change specific file permissions using udev rule and what am I doing wrong?

Guy
  • 491
  • 4
  • 13
  • 2
    Several things to consider: is there a later rule that overwrites this? You use a fullpath for `find` but not for `chown` or `chmod`, are they on the path? Are those actually files (`-type f`), most things under `/sys/class` are symlinks or directories on my system. – Cupcake Protocol Sep 13 '18 at 19:08
  • I have tried to change the file name to 90-brightness.rules so it will run last. the only other rule that exists in `/etc/udev/rules.d` is `70-snap.core.rules` so it is not supposed to override my rule. If I run `/usr/bin/find /sys/class/backlight/intel_backlight/ -type f -name brightness -exec /bin/chown bob:bob {} \; -exec /bin/chmod 666 {} \;` in the command line it works fine, but if I run it in my dev rule it still does not work. – Guy Sep 16 '18 at 08:52

1 Answers1

3

I have solved the problem,

the dev-rule should look like this (without the backslashes)

KERNEL=="intel_backlight", SUBSYSTEM=="backlight", RUN+="/usr/bin/find /sys/class/backlight/intel_backlight/ -type f -name brightness -exec chown bob:bob {} ; -exec chmod 666 {} ;"

But note that the above RUN command won't work on the terminal command line (for that you need to have the backslashes)

Guy
  • 491
  • 4
  • 13
  • You don't need to use `find` if you can match the target file using for example `%p`. Just start with a full path to the command you actually want, for example: `RUN+="/bin/chmod 0666 /sys%p/brightness"` – Mikko Rantalainen Mar 06 '23 at 18:31