-
Notifications
You must be signed in to change notification settings - Fork 10
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
Doesn't alter the brightness on Wayland. #25
Comments
Wasn't this one fixed by using the Also which screen is this, the USB-C screen? I know I have a similar issue on one of my monitors where the library sets the brightness and the display also says the brightness has been set, but doesn't apply it until I power cycle the display |
I've had to abandon Therefore, I refer solely to the default method – when the function is invoked without arguments. It definitely works on X, but not Wayland. Same monitor, although I've tested the code on some different Windows machines (with different monitors) and it works, because of course Windows works and Linux doesn't – it's always the way. |
So if I'm understanding this correctly:
I guess this is XRandr doing its thing. Xrandr tends to work great on X because it doesn't actually change the brightness, just applies a filter to make the screen look dimmer. Unfortunately, XRandr doesn't work on wayland.
The only difference this library makes when calling ddcutil is retrying upon failure and adjusting a few performance parameters. Here are the parameters the library sets:
You could try adjusting the sleep multiplier. I've pushed an update to the issue25 branch that should allow you to do this: import screen_brightness_control as sbc
sbc.linux.DDCUtil.sleep_multiplier = 1 # change the sleep multiplier back to default
sbc.linux.DDCUtil.cmd_max_tries = 3 # set max retries to 3, default is 10
sbc.linux.DDCUtil.enable_async = False # disable setting the --async flag
sbc.set_brightness(40, method='ddcutil')
sbc.get_brightness(method='ddcutil') You can see if this makes a difference. Also, out of curiosity, the screen doesn't have any sort of auto brightness/dimming feature enabled? |
Wayland
PS /home/rokejulianlockhart> groups $Env:USER
rokejulianlockhart : rokejulianlockhart users wheel vboxusers i2c PS /root> groups $Env:USER
root : root i2c This appears to be, due to the delay when invoking it as And indeed, no matter whether it invokes or not, it doesn't actually change the brightness. I've recently changed from Fedora to OpenSUSE, so something might have changed, but this seems consistent with what I've previously witnessed too. I did manage a moment ago to get an error messsage though: >>> sbc.get_brightness(method='ddcutil')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rokejulianlockhart/.local/lib/python3.10/site-packages/screen_brightness_control/__init__.py", line 50, in get_brightness
return __brightness(display=display, method=method, meta_method='get', verbose_error=verbose_error)
File "/home/rokejulianlockhart/.local/lib/python3.10/site-packages/screen_brightness_control/__init__.py", line 769, in __brightness
for monitor in filter_monitors(display=display, method=method):
File "/home/rokejulianlockhart/.local/lib/python3.10/site-packages/screen_brightness_control/__init__.py", line 737, in filter_monitors
raise NoValidDisplayError(msg)
screen_brightness_control.exceptions.NoValidDisplayError: no displays detected with method: 'ddcutil' >>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>> sbc.get_brightness(method='ddcutil')
DEBUG:screen_brightness_control:brightness get request display None with method ddcutil
DEBUG:screen_brightness_control.helpers:cache get 'ddcutil_monitors_info' = [KeyError]
WARNING:screen_brightness_control.linux:error grabbing display info from <class 'screen_brightness_control.linux.DDCUtil'> - TypeError: CalledProcessError.__init__() missing 1 required positional argument: 'cmd'
DEBUG:screen_brightness_control.helpers:cache get 'ddcutil_monitors_info' = [KeyError]
WARNING:screen_brightness_control.linux:error grabbing display info from <class 'screen_brightness_control.linux.DDCUtil'> - TypeError: CalledProcessError.__init__() missing 1 required positional argument: 'cmd'
DEBUG:screen_brightness_control.helpers:cache get 'ddcutil_monitors_info' = [KeyError]
WARNING:screen_brightness_control.linux:error grabbing display info from <class 'screen_brightness_control.linux.DDCUtil'> - TypeError: CalledProcessError.__init__() missing 1 required positional argument: 'cmd'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rokejulianlockhart/.local/lib/python3.10/site-packages/screen_brightness_control/__init__.py", line 50, in get_brightness
return __brightness(display=display, method=method, meta_method='get', verbose_error=verbose_error)
File "/home/rokejulianlockhart/.local/lib/python3.10/site-packages/screen_brightness_control/__init__.py", line 769, in __brightness
for monitor in filter_monitors(display=display, method=method):
File "/home/rokejulianlockhart/.local/lib/python3.10/site-packages/screen_brightness_control/__init__.py", line 737, in filter_monitors
raise NoValidDisplayError(msg)
screen_brightness_control.exceptions.NoValidDisplayError: no displays detected with method: 'ddcutil'
>>> X
with the portable monitor attached
This appears to demonstrate that on X, the names of the devices are passed to
Not that I know of.>>> sbc.list_monitors()
['DP-2'] >>> sbc.list_monitors()
['DP-2', 'HDMI-A-1']
I dare say that I've little experience even pulling a branch from Also, per https://crozzers.github.io/screen_brightness_control/extras/Installing%20On%20Linux.html, is there a way of discovering the potential methods? I'd like to try each independently. |
Have you tried power cycling the display? I have occasionally found that to help
I've pushed the remaining changes to main, since most of it was already there. If you have git installed you can follow the instructions on the readme for cloning the repo. The only thing now on main that isn't part of the latest release is the
The If you could go through each method and figure out which ones work on X, which ones work on Wayland and put it all in a table or something that would be helpful. The root/non root stuff I'm not as concerned about since that is probably a permissions issue. |
@Crozzers, I've executed the example at the PS /home/rokejulianlockhart> Write-Output "$Env:USER"
rokejulianlockhart XPowerShell 7.4.0-preview.2
PS /home/rokejulianlockhart> script -c pwsh Script started, output log file is 'typescript'.
PowerShell 7.4.0-preview.2
PS /home/rokejulianlockhart> python3 Python 3.10.10 (main, Mar 01 2023, 21:10:14) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import screen_brightness_control as sbc
>>> import screen_brightness_control as sbc
>>>
>>> all_methods = sbc.get_methods()
>>>
>>> for method_name, method_class in all_methods.items():
... print('Method:', method_name)
... print('Class:', method_class)
... print('Associated monitors:', sbc.list_monitors(method=method_name))
...
Method: sysfiles
Class: <class 'screen_brightness_control.linux.SysFiles'>
Associated monitors: []
Method: i2c
Class: <class 'screen_brightness_control.linux.I2C'>
Associated monitors: []
Method: xrandr
Class: <class 'screen_brightness_control.linux.XRandr'>
Associated monitors: ['Q3279WG5B']
Method: ddcutil
Class: <class 'screen_brightness_control.linux.DDCUtil'>
Associated monitors: []
Method: light
Class: <class 'screen_brightness_control.linux.Light'>
Associated monitors: []
>>> exit() PS /home/rokejulianlockhart> tty
/dev/pts/4 WaylandPowerShell 7.4.0-preview.2
PS /home/rokejulianlockhart> python3 Python 3.10.10 (main, Mar 01 2023, 21:10:14) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import screen_brightness_control as sbc
>>> all_methods = sbc.get_methods()
>>> for method_name, method_class in all_methods.items():
... print('Method:', method_name)
... print('Class:', method_class)
... print('Associated monitors:', sbc.list_monitors(method=method_name))
...
Method: sysfiles
Class: <class 'screen_brightness_control.linux.SysFiles'>
Associated monitors: []
Method: i2c
Class: <class 'screen_brightness_control.linux.I2C'>
Associated monitors: []
Method: xrandr
Class: <class 'screen_brightness_control.linux.XRandr'>
Associated monitors: ['DP-2']
Method: ddcutil
Class: <class 'screen_brightness_control.linux.DDCUtil'>
Associated monitors: []
Method: light
Class: <class 'screen_brightness_control.linux.Light'>
Associated monitors: []
>>> exit() PS /home/rokejulianlockhart> tty
/dev/pts/2 Aren't these results weird? I didn't expect XRandr to work on Wayland, much less it to be the only one that actually outputs anything. I realize that you weren't particularly interested in the differences between the superuser and regular users, but I just wanted to include some results in here with the answer to your comment anyway:
|
Do you have ddcutil installed on your new OS with all the right permissions? Xrandr won't work correctly on wayland and so the only other ways of changing the brightness for your monitor will be I remember there were some issues with DDCUtil hanging the system but you could try experimenting with the flags I added to see if you can alleviate the issues. If you play around with different values in the flags within this code snippet: import logging
logging.basicConfig(filename='test.log', level=logging.DEBUG, filemode='w')
import screen_brightness_control as sbc
sbc.linux.DDCUtil.sleep_multiplier = 1 # change the sleep multiplier back to default (0.5 means half the usual time)
sbc.linux.DDCUtil.cmd_max_tries = 3 # set max retries to 3, default is 10
sbc.linux.DDCUtil.enable_async = False # disable setting the --async flag
sbc.set_brightness(40, method='ddcutil')
print(sbc.get_brightness(method='ddcutil'))
print('===================LOGS===================')
with open('test.log', 'r') as f:
print(f.read()) And of course, if you could make sure to do this in some test script, not as part of another program, like the GUI app you were developing. This issue has gone so many ways with so much going on, I'd like to just make sure we're doing the same stuff. My thinking for pushing ddcutil is that if ddcutil works but is hanging when called from this library, then all we need to do is fix the hanging. Root or non-root doesn't matter, that's a permissions issue that I cannot do much about. As long as there is a way to get it working then we can build from there |
As previously demonstrated, the code operates without error, yet the brightness of my screen is not modified despite the value consistently returning the integer of the brightness that I have previously instructed it to apply. This code operates on X.
The text was updated successfully, but these errors were encountered: