Open guyzmo opened 7 years ago
After reading some other issue, I found out that dux
needs access to /sys
, so I looked at the source to find the exact full path it needs to access.
So I did a hack to solve it, which was to chown the files within the directory pointed by the link:
sudo chown $USER:root /sys/class/backlight/*
it's far from perfect, but does the job.
I believe there should be a more appropriate way to control brightness settings, using either xset
or DBUS
… At least, if the /sys
path is the way to go, then maybe starting as root to open the fds, and downgrading the daemon to user mode could do the job.
Also, like others around, even if inc
and dec
work, I can't get a profile to work, I tried all three window
, desktop
and luminance
with no success. I'd rather follow up on this on the other issues #3 and #6.
The sysfs interface is only used if XRandr is not found, recent enough, or broken.
xrandr definitely works, and here's its version:
% xrandr --version
xrandr program version 1.5.0
Server reports RandR version 1.5
I guess I'll have another look at some point, and try to input debug printouts in the code to check why it's not using xrandr. I've never done any rust, and TBH, it makes me feel a coding newbie again ☺
Thank you for this code, BTW! ☺
I'll try to investigate, it may be happening on my system too but I never noticed because I had the right permissions for testing the sysfs code.
If I can't reproduce it then yeah, good luck 🐼
maybe a nice thing would be to document what would be needed for having xrandr actually working :-s
I think the problem is that xcb::intern_atom
returns a xcb::ATOM_NONE
for both "Backlight" and "BACKLIGHT" (https://github.com/meh/dux/blob/master/src/backlight/randr.rs#L36).
What is very weird is that this also occurs with "xbacklight", the tool from where, I think, the randr method for dux comes from.
Anyway, dux cannot use randr, so it defaults to using /sys/class/backlight/
, but it fails in my machine as only root can modify files under that path. The solution I found was copy-pasting some Udev rules other backlight tools have implemented, so that my user gets some rights to modify files under the path. The procedure was:
Dux works without any problem after restarting.
If anyone is curious on how changing the backlight works, I suggest you go take a look at other tools that do the same in other languages. Some of them are:
https://wiki.archlinux.org/index.php/Backlight#Backlight_utilities. Btw, nobody cares about randr. All other tools modify /sys/class/backlight
and have some udev rules.
Here's the full stacktrace (with
RUST_BACKTRACE=1
) of the error I had: