LordAmit / Brightness

Using Brightness Controller, you can control brightness of both primary and external displays in Linux. Check it out!
Other
1.04k stars 82 forks source link

Cannot run brightness-controller after installing. Python error with index out of range. #248

Open MartinSkold opened 7 months ago

MartinSkold commented 7 months ago

I installed it, installed ddcutil using sudo apt install ddcutil, but the application crashes at start. Is there some permissions I need to set?

╰ [10:08:14] $ brightness-controller
Open failed for /dev/i2c-3: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-4: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-5: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-6: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-7: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-8: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-9: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-10: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-11: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-12: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-13: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-14: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-15: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-16: errno=EACCES(13): Permission denied
Open failed for /dev/i2c-17: errno=EACCES(13): Permission denied
Traceback (most recent call last):
  File "/home/xxxxxx/miniconda3/bin/brightness-controller", line 8, in <module>
    sys.exit(main())
  File "/home/xxxxxx/miniconda3/lib/python3.10/site-packages/brightness_controller_linux/init.py", line 903, in main
    WINDOW = MyApplication()
  File "/home/xxxxxx/miniconda3/lib/python3.10/site-packages/brightness_controller_linux/init.py", line 139, in __init__
    self.generate_dynamic_items()
  File "/home/xxxxxx/miniconda3/lib/python3.10/site-packages/brightness_controller_linux/init.py", line 267, in generate_dynamic_items
    self.generate_brightness_sources()
  File "/home/xxxxxx/miniconda3/lib/python3.10/site-packages/brightness_controller_linux/init.py", line 282, in generate_brightness_sources
    self.ui.secondary_combo.addItem(self.displayNames[i])
IndexError: list index out of range

Version brightness-controller-linux==2.4

To Reproduce Steps to reproduce the behavior:

pip install brightness-controller-linux
sudo apt install ddcutil

starting app with brightness-controller in terminal

Expected behavior Not a index out of range?

Desktop (please complete the following information):

Running on a Dell Inc. Precision 5560

Additional context Am I missing any instructions?

archisman-panigrahi commented 7 months ago

See I2C Device Permissions section in https://www.ddcutil.com/config_steps/

thardev commented 2 months ago

Hi @archisman-panigrahi

I'm experiencing a similar problem and I think it might be a bug :thinking: This is the output that I get when I run the ddcutil detect command for the first time with the correct permissions. And then, as you can see, the built-in display is no longer detected. Screenshot_20240626_182504 So after this happens, from what I understand of the implementation, xrandr is used to detect the number of displays, and when I run the xrandr --query command, as it is used here I correctly get two displays connected. Screenshot_20240626_182851

So, I suspect that during the init of the app, xrandr detects two displays but ddcutil only one, so when the following variable is filled, it contains two displays. https://github.com/LordAmit/Brightness/blob/dab46e312e04948b8a4286de169782bde43c6032/brightness-controller-linux/brightness_controller_linux/init.py#L50-L52

Finally, when it reaches the following line, an error is thrown since the self.displayNames comes from ddcutil output not from xrandr. https://github.com/LordAmit/Brightness/blob/dab46e312e04948b8a4286de169782bde43c6032/brightness-controller-linux/brightness_controller_linux/init.py#L281-L284

This is the error that I see on the logs. Screenshot_20240626_183442

If needed I can create a separate issue for this. Thank you very much for your work!

Soggy-Pancake commented 1 month ago

@thardev Thanks for the bug report! Can you also try my fork? https://github.com/Soggy-Pancake/Brightness-Direct-Control I just made some changes that should hopefully fix the problem.

The problem was that in CDisplay.match_ddc_order it was failing to add the laptop display and it was still counted so it then tried to load the reordered names missing the laptop display.

I also added several other patches since my last pull request that improves the ddcutil mode.

thardev commented 1 month ago

Hi @Soggy-Pancake

Thank you for your answer 🙂 I did try your fork but I don't seem to be able to make it work properly, I've followed the instructions of this README https://github.com/Soggy-Pancake/Brightness-Direct-Control/blob/master/brightness-controller-linux/README.md but the app crashes when I try to adjust the brightness. Probably I need to install it system wide properly? Or what else could it be?

Soggy-Pancake commented 1 month ago

What is the traceback when it crashes?

DDCutil needs to be installed if you are using direct backlight control but you should be able to run the brightness controller from any location.

Soggy-Pancake commented 1 week ago

@thardev Can you please provide the traceback for the crash when attempting to change brightness?