* [Question] On defining udev rules in system configuration
@ 2023-09-18 2:09 Rodrigo Morales
2023-09-18 2:20 ` Rodrigo Morales
2023-09-18 2:44 ` Felix Lechner via
0 siblings, 2 replies; 4+ messages in thread
From: Rodrigo Morales @ 2023-09-18 2:09 UTC (permalink / raw)
To: help-guix
[-- Attachment #1: Type: text/plain, Size: 2836 bytes --]
* 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.
[-- Attachment #2: config-system-sony-wayland.scm --]
[-- Type: text/x-scheme, Size: 3007 bytes --]
(use-modules (gnu))
(use-service-modules
networking
ssh
avahi
;; sddm-service-type
sddm
;; gdm-service-type
xorg
;; %desktop-services
desktop)
(use-package-modules
ssh
certs)
(define %my-services
;; We need to modify the service. Otherwise, we get the following
;; error
;;
;; guix system: error: service 'guix-daemon' provided more than once
(modify-services
%desktop-services
(delete gdm-service-type)
(guix-service-type
config =>
(guix-configuration
(inherit config)
(discover? #t)
(authorized-keys
(append (list (local-file "./public-keys/delta.pub"))
%default-authorized-guix-keys))))
(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)))))))
(operating-system
(host-name "sony")
(locale "en_US.utf8")
(timezone "America/Lima")
(bootloader
(bootloader-configuration
(bootloader grub-efi-bootloader)
(targets '("/boot/efi"))))
(file-systems
(cons*
(file-system
(device (file-system-label "my-efi"))
(mount-point "/boot/efi")
(type "vfat"))
(file-system
(device (file-system-label "my-root"))
(mount-point "/")
(type "ext4"))
(file-system
(device (file-system-label "my-home"))
(mount-point "/home")
(type "ext4"))
%base-file-systems))
(users
(cons
(user-account
(name "rdrg")
(comment "This is a comment for user rdrg")
(group "users")
(supplementary-groups
'(;; Make the user a sudoer
"wheel"
;; Allow the user to play sound
"audio"
;; Allow the user to access the webcam
"video")))
%base-user-accounts))
;; Globally-installed packages
(packages
(cons*
;; This is mandatory. Otherwise, the following error will be shown:
;; SSL certificate is invalid. Information on how to fix such
;; problem on
;; https://github.com/pjotrp/guix-notes/blob/927a46dc754770ec52d3ac047b58a1ac6fbb6a64/INSTALL.org#guix-pull-error-git-error-the-ssl-certificate-is-invalid
nss-certs
%base-packages))
(services
(cons*
;; SSH server
(service openssh-service-type
(openssh-configuration
(openssh openssh-sans-x)
(port-number 2222)))
;; TODO: This doesn't make sddm show sway.
;;
;; SEE: https://lists.gnu.org/archive/html/help-guix/2020-12/msg00235.html
;; (service sddm-service-type
;; (sddm-configuration
;; (auto-login-user "rdrg")
;; (auto-login-session "sway.desktop")
;; (display-server "wayland")))
%my-services)))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Question] On defining udev rules in system configuration
2023-09-18 2:09 [Question] On defining udev rules in system configuration Rodrigo Morales
@ 2023-09-18 2:20 ` Rodrigo Morales
2023-09-18 2:44 ` Felix Lechner via
1 sibling, 0 replies; 4+ messages in thread
From: Rodrigo Morales @ 2023-09-18 2:20 UTC (permalink / raw)
To: help-guix
Solved! I had to also run =chmod= (see complete configuration for
=udev-service-type= below)
#+BEGIN_SRC scheme
(udev-service-type
config =>
(udev-configuration
(inherit config)
(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"
"ACTION==\"add\","
"SUBSYSTEM==\"backlight\","
"RUN+=\"/run/current-system/profile/bin/chmod g+w
/sys/class/backlight/intel_backlight/brightness\""))
,@(udev-configuration-rules config)))))
#+END_SRC
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Question] On defining udev rules in system configuration
2023-09-18 2:09 [Question] On defining udev rules in system configuration Rodrigo Morales
2023-09-18 2:20 ` Rodrigo Morales
@ 2023-09-18 2:44 ` Felix Lechner via
2023-09-18 6:11 ` Rodrigo Morales
1 sibling, 1 reply; 4+ messages in thread
From: Felix Lechner via @ 2023-09-18 2:44 UTC (permalink / raw)
To: Rodrigo Morales; +Cc: help-guix
Hi Rodrigo,
On Mon, Sep 18 2023, Rodrigo Morales wrote:
> I've defined the following udev-rule in my configuration
You are lucky your rule works! [1] Does udevadm find your rule?
Kind regards
Felix
[1] https://issues.guix.gnu.org/63508#3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Question] On defining udev rules in system configuration
2023-09-18 2:44 ` Felix Lechner via
@ 2023-09-18 6:11 ` Rodrigo Morales
0 siblings, 0 replies; 4+ messages in thread
From: Rodrigo Morales @ 2023-09-18 6:11 UTC (permalink / raw)
To: Felix Lechner; +Cc: help-guix
Could you tell me what's the complete command that you are referring
to? I'm not very familiar with udevadm.
On Mon, 18 Sept 2023 at 02:44, Felix Lechner <felix.lechner@lease-up.com> wrote:
>
> Hi Rodrigo,
>
> On Mon, Sep 18 2023, Rodrigo Morales wrote:
>
> > I've defined the following udev-rule in my configuration
>
> You are lucky your rule works! [1] Does udevadm find your rule?
>
> Kind regards
> Felix
>
> [1] https://issues.guix.gnu.org/63508#3
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-18 6:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-18 2:09 [Question] On defining udev rules in system configuration Rodrigo Morales
2023-09-18 2:20 ` Rodrigo Morales
2023-09-18 2:44 ` Felix Lechner via
2023-09-18 6:11 ` Rodrigo Morales
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).