-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logind fallback support for unprivileged users #83
Conversation
Wow, very interesting, thanks for sharing! What do you think about swapping the priorities, and first try dbus, and only then fallback to write to files, is it a bad idea? On the one hand, it sounds better to promote feature that needs less permissions, on the other hand, is it perhaps noticeably slower to change brightness via dbus, or perhaps it's hard to see via code whether it worked, whether we need to fallback to file? And thanks for sharing a link to |
I've modified this code a bit and, having limited ability to test it on my own machine, found that before these changes it was about 30x slower than writing to a file, now it's at least as fast, and possibly 2-3x faster. |
Okay, thanks! And just to clarify, I'm not opposed to use file first, checking for write assess like you also do in slight, I'm just curious to learn what pros and cons there are; in fact @cyrinux was telling me in another chat that trying file first is a better approach 🙃 |
Sorry for misunderstanding. I think if the user already has permissions, it's really better to set the brightness via a file, since the Also, there is no easy way to check for write permission (I just found out that my method from |
I agree with you on everything, let's do as you propose, using file as the first option, using the check of trying to write the current brightness, and using the slower dbus that tells us about whether it succeeded or failed. Will get it tested, and merged afterwards. Huge thanks once more, not only for the idea, but especially for an actual PR! |
All done, Thanks! |
I hope you don't mind working directly into your PR 😉 The most interesting result of a test so far is that with external displays, the time we need to wait for a dbus call response is ~10 times larger than the proposed 100ms 😐 That's why I returned back to your earlier commit of just using a non-blocking Otherwise, since we are anyway checking for file permissions only once, I made it skip dbus initialization entirely, when we know it won't be used. |
elogind
orsystemd-logind
provide a safe interface for unprivileged users to control device's brightness throughdbus
. So I implemented support for setting backlight brightness when user is neither running program asroot
nor part ofvideo
group.Unfortunately I've never used
wluma
myself and currently I am not able to. So this changes is not tested. But this exact code works as expected in my own brightness control utility and I think support oflogind
fallback will be nice addition towluma
features.More info