Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] How does / did x11-apps/xbacklight change settings?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Tue Jun 21, 2022 4:32 am    Post subject: [solved] How does / did x11-apps/xbacklight change settings? Reply with quote

Neither xbacklight nor xrandr have setuid/setgid bits set. Other than being in the video group, no special permissions appeared necessary.

Code:
$ xrandr --listactivemonitors
Monitors: 1
 0: +*eDP-1 1920/309x1080/174+0+0  eDP-1

$ find /sys/devices/ -name "*eDP*"
/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1

$ cat /sys/devices/pci0000\:00/0000\:00\:02.0/drm/card0/dev
226:0

$ ls -l /dev/dri/card0
crw-rw---- 1 root video 226, 0 Jun 19 06:06 /dev/dri/card0

$ echo 500 > /sys/class/backlight/intel_backlight/brightness
bash: /sys/class/backlight/intel_backlight/brightness: Permission denied
I can't modify the brightness setting as a normal user.

Other than needing to be root, interacting with the /sys/class files seems easy enough, so I was considering writing my own utility to do so.

That's how acpilight appears to function. The ebuild for acpilight requires acct-group/video and mentions the need to be a member of that group.

However, I don't see anywhere indicating how it can modify /sys/class files which are group owned by root, not video (at least the ones I've looked at), so acpilight's xbacklight command having group video membership doesn't seem to be the answer.

What piece am I missing that allows either x11-apps/xbacklight or acpilight to make those changes?
_________________
Quis separabit? Quo animo?


Last edited by pjp on Tue Jun 21, 2022 2:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6098
Location: Dallas area

PostPosted: Tue Jun 21, 2022 9:24 am    Post subject: Reply with quote

Code:
$ grep DESC /usr/portage/x11-apps/xbacklight/xbacklight-1.2.3.ebuild
DESCRIPTION="Sets backlight level using the RandR 1.2 BACKLIGHT output property"


https://wiki.archlinux.org/title/backlight has some info that might be useful

Acpilight should just work though.
What are the permissions on /sys/class/backlight/*

And

It's easy enough to change permissions on those files when booting up, I like to use /etc/local.d/baselayout1.start for things like that.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Tue Jun 21, 2022 2:10 pm    Post subject: Reply with quote

I noticed that description, which is why I looked at xrandr. It of course says to use xbacklight :)

I guess xrandr is probably implementing "RandR 1.2" and I'd have to look at its code.


Changing permissions was the clue, although it seems like a hackish solution. acpilight has a udev rule which does that as well as changing group ownership. I was anticipating whatever it implemented would be more "involved" that reading and writing those files.

Thanks!
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6098
Location: Dallas area

PostPosted: Tue Jun 21, 2022 4:13 pm    Post subject: Reply with quote

There's not much more than reading/writing :lol:
I don't have a problem using the /sys subsystem, it's simply a raw interface to many things in the kernel/modules.

xrandr --help gives
Code:
...
  --output <output>
      --auto
      --mode <mode>
      --preferred
      --pos <x>x<y>
      --rate <rate> or --refresh <rate>
      --reflect normal,x,y,xy
      --rotate normal,inverted,left,right
      --left-of <output>
      --right-of <output>
      --above <output>
      --below <output>
      --same-as <output>
      --set <property> <value>
      --scale <x>[x<y>]
      --scale-from <w>x<h>
      --transform <a>,<b>,<c>,<d>,<e>,<f>,<g>,<h>,<i>
      --filter nearest,bilinear
      --off
      --crtc <crtc>
      --panning <w>x<h>[+<x>+<y>[/<track:w>x<h>+<x>+<y>[/<border:l>/<t>/<r>/<b>]]]
      --gamma <r>[:<g>:<b>]
      --brightness <value>
      --primary


So brightness should work, using the latest xrandr 1.5.1, but I would favor just modifying permissions.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Tue Jun 21, 2022 5:01 pm    Post subject: Reply with quote

Maybe I'm lucky in that I have 0 udev rules, but it didn't even occur to me that something relevant would have been there. I guess it has been long enough that I mostly forgot why they exist.

Quote:
--brightness brightness
Multiply the gamma values on the crtc currently attached to the output to specified floating value. Useful for overly bright or
overly dim outputs. However, this is a software only modification, if your hardware has support to actually change the bright‐
ness, you will probably prefer to use xbacklight.
It wasn't readily obvious what crtc was and the mentioned differentiation between software and hardware seemed to indicate there was a difference between using xrandr's brightness option and that of the non-acpilight xbacklight.

If using /sys is the "correct" way to do it, then I'll use that method, but it still seems like a hack *shrug*. Changing ownership and permissions is a standard Unix way of doing things, so at least there's that, which is nice.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1530
Location: South America

PostPosted: Wed Jun 22, 2022 3:12 am    Post subject: Re: Reply with quote

pjp wrote:
Neither xbacklight nor xrandr have setuid/setgid bits set. [...]
What piece am I missing that allows either x11-apps/xbacklight or acpilight to make those changes?

I don't know about acpilight, but xbacklight doesn't actually make the changes itself. It is an X client, and asks the X server to make them.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Wed Jun 22, 2022 4:00 am    Post subject: Re: Reply with quote

GDH-gentoo wrote:
pjp wrote:
Neither xbacklight nor xrandr have setuid/setgid bits set. [...]
What piece am I missing that allows either x11-apps/xbacklight or acpilight to make those changes?

I don't know about acpilight, but xbacklight doesn't actually make the changes itself. It is an X client, and asks the X server to make them.
That's what I was guessing. And as I'm using startx, I presumed that came into play, but I wasn't finding any details. And since running xbacklight as a normal user worked without special consideration, I had no clue how to even search for that information. I'm guessing only in code, which I'd almost certainly have trouble finding.

The acpilight version uses udev rules to change /sys/class/backlight/... group ownership to video, group writable. The code itself simply modifies those files. (a fancier 'echo $value > /path/to/file'). Since using echo worked after the original xbacklight stopped functioning, I wondered how other solutions worked, thinking they used some other "official" mechanism.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum