You are not logged in.

#1 2015-05-23 09:35:02

danijar
Member
Registered: 2015-05-05
Posts: 5

How to write a udev rule to change group and permissions of backlight?

Hello,

My backlight device is located under /sys/class/backlight/intel_backlight/backlight. I already managed to map the function keys of my laptop to it by writing a small script, but in order to set a new brightness value, the user needs write permissions on the device. Therefore, I changed the group of it to a new one called devices, added the user to that group, and added write permissions for the group.

This works, but group ownership and write permissions are reset after each reboot. There is already an old thread addressing this using the rc-local service, but I guess udev rules are the proper way to do this. However, from the guide on writing udev rules linked in the Arch wiki, I don't get managed to write the rule to set group and write permissions of my device.

Is this a use case for udev rules? If so, could you please help me writing the according rule?

Offline

#2 2015-05-23 10:08:31

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,749
Website

Re: How to write a udev rule to change group and permissions of backlight?

Does the `xbacklight` command work?

It may be simpler to use `sudo tee` and use "NOPASSWD"  for `tee` in /etc/sudoers albeit at the cost of greatly reducing security...

Have you read this guide to udev rules?
http://www.reactivated.net/writing_udev_rules.html

Another alternative would be a custom unit file for systemd:
https://wiki.archlinux.org/index.php/Sy … unit_files

Offline

#3 2015-05-23 19:08:56

danijar
Member
Registered: 2015-05-05
Posts: 5

Re: How to write a udev rule to change group and permissions of backlight?

xbacklight doesn't work, so I wrote a small bash script that reads max_brightness and writes into the brightness device. Using NOPASSWD sounds a bit hacky to me. I could do this, but if there is a better way, I'd prefer this.

Yes, I read though the guide. This is what I came up with. The file is located at /etc/udev/rules.d/backlight.rules.

SUBSYSTEM="backlight" DEVPATH="*/intel_backlight" GROUP="devices" MODE="0660"

However, the rule is not working. How can I further debug it?

Offline

Board footer

Powered by FluxBB