Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm starting X as a user and need to set my keyboard brightness in /sys/class/leds/asus\:\:kbd_backlight/brightness. The /sys/ directory gets recreated after reboot, so the permissions will reset too. How do I set it up so I don't need to make the file writable by all users after every boot?

I'm using Archlinux with SDDM as the login manager and KDE as DE.

share|improve this question
1  
You could put a command in a systemd boot service. –  TAFKA 'goldilocks' Mar 23 '13 at 13:52
    
Are you meaning to create a own systemd service which set the permissions? Or do you talk from a specific file? –  Timo Mar 23 '13 at 14:04
    
The former. "Service" is the systemd term, even though in this case it would just be a one-off command and not a daemon. You could make it a kind of "miscellaneous stuff" service like rc.local is under sysV. In this case the service just runs a shell script, and you put the command in there. –  TAFKA 'goldilocks' Mar 23 '13 at 14:31
add comment

2 Answers

up vote 1 down vote accepted

No you can't, the permission of sysfs is defined in kernel space and can't be changed with userspace tools (unless with kernel side support).

But for your own problem, you could setup a sudo entry that allow everyone to write to that path, i.e ALL ALL = (ALL) NOPASSWD: /usr/bin/tee /sys/class/leds/asus\:\:kbd_backlight/brightness

And when you write to that directory, use a script like this, echo 1 | sudo /usr/bin/tee "/sys/class/leds/asus::kbd_backlight/brightness"

share|improve this answer
    
I tried that, but it asks always for the password. I also tried to add a NOPASSWD: behind the (ALL). –  Timo Mar 29 '13 at 16:19
    
@Timo can you try again? See my updates –  warl0ck Mar 29 '13 at 22:55
    
It works now. The problem was that my entry was overwritten by another one without NOPASSWD. And i accepted your answer because it was easier as the other answers. Thanks all. –  Timo Mar 30 '13 at 18:24
add comment

The /sys directory in Linux is fake, it is a view into the kernel dressed up as files. So to change permissions in it permanently means hackig the kernel, and that would be ill-advised. As the comments say, perhaps a systemd unit setting this would be a solution (in general, set the change up as part of the boot process).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.