[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Question] On defining udev rules in system configuration
|
From: |
Rodrigo Morales |
|
Subject: |
[Question] On defining udev rules in system configuration |
|
Date: |
Mon, 18 Sep 2023 02:09:15 +0000 |
* The problem
I've defined the following udev-rule in my configuration (full
configuration attached)
#+BEGIN_SRC scheme
(... some omitted lines ...)
(udev-service-type
config =>
(udev-configuration
(inherit config)
;; SEE:
https://unix.stackexchange.com/questions/459874/udev-doesnt-want-to-run-chgrp-and-chmod
(rules
`(,(udev-rule
"90-backlight.rules"
(string-append
"ACTION==\"add\","
"SUBSYSTEM==\"backlight\","
"RUN+=\"/run/current-system/profile/bin/chgrp video
/sys/class/backlight/intel_backlight/brightness\""
"\n"
))
,@(udev-configuration-rules config)))))
(... some omitted lines ...)
#+END_SRC
This made it possible to change the gorup for the file (see proof below)
#+BEGIN_SRC sh
ls -l /sys/class/backlight/intel_backlight/brightness
#+END_SRC
#+RESULTS:
#+BEGIN_EXAMPLE
-rw-r--r-- 1 root video 4096 Sep 17 20:48
/sys/class/backlight/intel_backlight/brightness
#+END_EXAMPLE
I'm user =rdrg= (see proof below)
#+BEGIN_SRC sh
whoami
#+END_SRC
#+RESULTS:
#+begin_example
rdrg
#+end_example
I belong to group =video= (see proof below)
#+BEGIN_SRC sh
cat /etc/group
#+END_SRC
#+RESULTS:
#+begin_example
root:x:0:
wheel:x:999:rdrg,rdrg-experiments
users:x:998:
nogroup:x:997:
tty:x:996:
dialout:x:995:
kmem:x:994:
input:x:993:
video:x:992:rdrg,rdrg-experiments,gdm
audio:x:991:rdrg,rdrg-experiments
netdev:x:990:rdrg,rdrg-experiments
lp:x:989:
disk:x:988:
floppy:x:987:
cdrom:x:986:
tape:x:985:
kvm:x:984:guixbuilder01,guixbuilder02,guixbuilder03,guixbuilder04,guixbuilder05,guixbuilder06,guixbuilder07,guixbuilder08,guixbuilder09,guixbuilder10
guixbuild:x:30000:guixbuilder01,guixbuilder02,guixbuilder03,guixbuilder04,guixbuilder05,guixbuilder06,guixbuilder07,guixbuilder08,guixbuilder09,guixbuilder10
messagebus:x:983:
polkitd:x:982:
geoclue:x:981:
colord:x:980:
avahi:x:979:
scanner:x:978:
gdm:x:977:
sshd:x:976:
#+end_example
But I can't edit that file as a regular user (see proof below)
#+BEGIN_SRC sh
echo 0 > /sys/class/backlight/intel_backlight/brightness
echo Exit code: $?
#+END_SRC
#+RESULTS:
#+BEGIN_EXAMPLE
bash: /sys/class/backlight/intel_backlight/brightness: Permission denied
Exit code: 1
#+END_EXAMPLE
It is worth mentioning that I can edit that file as =sudo=
#+BEGIN_SRC sh
echo 0 | sudo tee /sys/class/backlight/intel_backlight/brightness
echo Exit code: $?
#+END_SRC
#+RESULTS:
#+BEGIN_EXAMPLE
0
Exit code: 0
#+END_EXAMPLE
* The questions
1. Why can't I edit =/sys/class/backlight/intel_backlight/brightness=
even though the file belongs to the =video= group?
2. What's the proper way to make it possible to edit
=/sys/class/backlight/intel_backlight/brightness=? I need to do this
because I want to define a keybinding in my windows manager that
changes the brightness.
config-system-sony-wayland.scm
Description: Text Data
- [Question] On defining udev rules in system configuration,
Rodrigo Morales <=