You are not logged in.

#1 2020-10-28 20:41:46

PanodGO
Member
Registered: 2020-03-21
Posts: 16

Adding udev rule for backlight doesn't work

Hi, I can 't set udev rule to allow my user using:

echo 6 > /sys/class/backlight/amdgpu_bl0/brightness

As you can see my class is amdgpu_bl0,

my /etc/udev/rules.d/backlight.rules

ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="amdgpu_bl0", GROUP="video", MODE="0664"

I have added user to group video:

~ groups
users video wheel

but still when using

sudo echo 6 > /sys/class/backlight/amdgpu_bl0/brightness

got

bash: sys/class/backlight/amdgpu_bl0/brightness: Permission denied

Pls any help wink

Offline

#2 2020-10-28 21:06:11

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,701

Re: Adding udev rule for backlight doesn't work

Not an answer to your problem, but your last command won't do it.

Try either:
echo 6 | sudo tee /sys/class/backlight/amdgpu_bl0/brightness
or
sudo bash -c "echo 6 > /sys/class/backlight/amdgpu_bl0/brightness"

The way you invoked it, the echo had been run as root, but then the output was redirected to /sys/class/backlight/amdgpu_bl0/brightness as your user.

But, what I think you are trying to do is to let your user write to that pseudo file in the first place.   I am not an expert here, but I suspect two things.  I don't know if udev rules effect pseudo file systems, and I don't know if the udev rules are executed before the pseudo file systems are created.   The other possibility is the pseudo file on which you are changing permissions may only be a soft link to another pseudo file.  Check that out; if it is, you might try changing the permissions  on the link target instead.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2020-10-28 21:18:46

PanodGO
Member
Registered: 2020-03-21
Posts: 16

Re: Adding udev rule for backlight doesn't work

I disagree. This one should clearly work:

echo 6 > /sys/class/backlight/amdgpu_bl0/brightness

brightness is just a pseudofile with a number. Writing a new number should def change brightness.

Problem is that this pseudofile has permissions:

-rw-r--r-- root root brightness

So I can't change it from user perspective. Thoguht this udev should work - it is from arch wiki after all, but apparently doesn't sad

Offline

#4 2020-10-28 22:06:18

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,701

Re: Adding udev rule for backlight doesn't work

You missed my point.  I agree that, if you accomplish what you are trying to do, that command will work.   I was talking about your having run that command with sudo  as you stated in your original post.  I was pointing out that the construction of that command only applies to the echo command, not to the redirection.   Yes, if the udev rule had worked, that command should work -- but then why the sudo?

The examples I gave will properly apply the sudo and will work even without a working udev rule; and I understand that is not what you want.   

Back to the original problem, so /sys/class/backlight/amdgpu_bl0/brightness is not a soft link?  The analogous pseudo file on my system is, although it is

ewaller@odin/home/ewaller % ll /sys/class/backlight/intel_backlight
lrwxrwxrwx 1 root root 0 Oct 26 12:41 /sys/class/backlight/intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight
ewaller@odin/home/ewaller % ll /sys/class/backlight/intel_backlight/
total 0
-r--r--r-- 1 root root 4096 Oct 28 13:57 actual_brightness
-rw-r--r-- 1 root root 4096 Oct 28 13:57 bl_power
-rw-r--r-- 1 root root 4096 Oct 28 13:58 brightness
lrwxrwxrwx 1 root root    0 Oct 28 13:57 device -> ../../card0-eDP-1
-r--r--r-- 1 root root 4096 Oct 26 12:41 max_brightness
drwxr-xr-x 2 root root    0 Oct 28 13:57 power
-r--r--r-- 1 root root 4096 Oct 28 13:57 scale
lrwxrwxrwx 1 root root    0 Oct 26 12:41 subsystem -> ../../../../../../../class/backlight
-r--r--r-- 1 root root 4096 Oct 26 12:41 type
-rw-r--r-- 1 root root 4096 Oct 26 12:41 uevent
ewaller@odin/home/ewaller % 

Last edited by ewaller (2020-10-28 22:06:50)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB