Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udev rules not working on Arch #25

Closed
StaticRocket opened this issue Sep 3, 2018 · 20 comments
Closed

udev rules not working on Arch #25

StaticRocket opened this issue Sep 3, 2018 · 20 comments

Comments

@StaticRocket
Copy link

OS: Arch Linux x86_64
Host: UX390UAK 1.0
Kernel: 4.18.5-arch1-1-ARCH

Udev rules

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

/bin/chgrp video /sys/class/backlight/%k/brightness returns
/bin/chgrp: cannot access '/sys/class/backlight/%k/brightness': No such file or directory

/sys/class/backlight is a file, not a directory, and it contains the following (viewed using nvim):

" ============================================================================
" Netrw Directory Listing                                        (netrw v156)
"   /sys/class/backlight
"   Sorted by      name
"   Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
"   Quick Help: <F1>:help  -:go up dir  D:delete  R:rename  s:sort-by  x:special
" ==============================================================================
../                                                                                                                  
./
intel_backlight@                  --> /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight

The same thing is occurring with the leds "directory". The current workaround is adding <username> ALL=(ALL) NOPASSWD: /bin/brightnessctl to the sudoers file as hinted by the readme.

@Hummer12007
Copy link
Owner

What does ls -l /sys/class/backlight/intel_backlight/ output?

@StaticRocket
Copy link
Author

ls -l /sys/class/backlight/intel_backlight/ returns

total 0
-r--r--r-- 1 root root 4096 Sep  4 10:24 actual_brightness
-rw-r--r-- 1 root root 4096 Sep  4 10:24 bl_power
-rw-r--r-- 1 root root 4096 Sep  4 10:54 brightness
lrwxrwxrwx 1 root root    0 Sep  4 10:24 device -> ../../card0-eDP-1
-r--r--r-- 1 root root 4096 Sep  4 10:24 max_brightness
drwxr-xr-x 2 root root    0 Sep  4 10:58 power
lrwxrwxrwx 1 root root    0 Sep  4 10:24 subsystem -> ../../../../../../../class/backlight
-r--r--r-- 1 root root 4096 Sep  4 10:24 type
-rw-r--r-- 1 root root 4096 Sep  4 10:24 uevent

@Hummer12007
Copy link
Owner

Let me double-check with you: are you executing the /bin/chgrp video /sys/class/backlight/%k/brightness in the shell, as opposed to adding udev rules?

@StaticRocket
Copy link
Author

I noticed the udev rule wasn't allowing the script to run without root privileges properly, so I ran the commands it was supposed to in the shell just to get some information for an issue report. (I'm new to troubleshooting udev rules.)

@Hummer12007
Copy link
Owner

I see, how weird. For the record, udev replaces %k with the device name (intel_backlight in this case).

@Hummer12007
Copy link
Owner

Hummer12007 commented Sep 4, 2018

Can you try it on the latest commit btw? (i.e. reinstall brightnessctl and reboot)

@StaticRocket
Copy link
Author

Done. No dice. (All I see is a version bump in the commits, so I don't think that will help much.)

@Hummer12007
Copy link
Owner

Hummer12007 commented Sep 5, 2018

And another question. Is your user account in the video group?

@StaticRocket
Copy link
Author

It wasn't, but I just added it and there was no effect.

@nkeor
Copy link

nkeor commented Sep 11, 2018

It happens to me too, but adding a sudo rule does not work. Arch up-to-date kernel 4.18.6

@ManuelSchmitzberger
Copy link

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"

@gdamjan
Copy link

gdamjan commented Jan 22, 2019

The proper way is to set the udev rules with uaccess:

ACTION=="add", SUBSYSTEM=="backlight", TAG+="uaccess"
ACTION=="add", SUBSYSTEM=="leds", TAG+="uaccess"

(edit: which (acls) is not supported on sysfs sigh)

@marcusbritanicus
Copy link

I have faced this issue. Till date I cannot directly modify /sys/class/backlight/%k/brightness and there seems to be a good reason behind it: /sys/class/backlight/%k is a symlink created and owned by root. So when you do chgrp on it, the link group does not change, but, the group of the link's target changes.

So in my case doing echo 100 > /sys/class/backlight/radeon_bl0/brightness gives permission error, where as echo 100 > /sys/devices/pci0000:00/0000:00:01.0/drm/card0/card0-eDP-1/radeon_bl0/brightness works like a charm!

@Hummer12007
Copy link
Owner

Is it still broken in brightnessctl in community?

@gdamjan
Copy link

gdamjan commented Aug 2, 2019

systemd-logind 243 (just around the corner now) will provide a dbus api for setting the brightness for the users seat.

@goetzc
Copy link

goetzc commented Aug 8, 2019

Is it still broken in brightnessctl in community?

@Hummer12007 yes.

@jay-aye-see-kay
Copy link

Is it still broken in brightnessctl in community?

community/brightnessctl 0.4-2 is working for me, my issue was not having my user in the video` group

For anyone else who finds this thread: sudo usermod -aG video $USER then logout and back in to add yourself to the video group

@goetzc
Copy link

goetzc commented Sep 22, 2019

@jay-aye-see-kay right, I missed this step from the README. As the Arch package no longer set the binary as suid, but ships the udev rules, the user has to be in the video group as you mention.

@gdamjan
Copy link

gdamjan commented Sep 22, 2019

since systemd 243 you don't need any special permissions on the system to change the backlight brightness. a user can do it for their seat by dbus calling logind.

this is already supported in brightnessctl, but we are waiting for a 0.5 release (hint hint @Hummer12007)

@gonzalezjo
Copy link

gonzalezjo commented Oct 22, 2019

I know this is a bit old, and this has seemingly been fixed on systems with a newer version of systemd, but this is a working solution in the meantime: Instead of chgrp, you can use chgrp -h to avoid dereferencing the symlink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants