Skip to content
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

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

Open
MartinSkold opened this issue Jan 31, 2024 · 14 comments

Comments

@MartinSkold
Copy link

MartinSkold commented Jan 31, 2024

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):

  • OS: Ubuntu 22.04.3 LTS
  • gnome version 42.9
  • Window system x11

Running on a Dell Inc. Precision 5560

Additional context
Am I missing any instructions?

@archisman-panigrahi
Copy link
Contributor

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

@thardev
Copy link

thardev commented Jun 26, 2024

Hi @archisman-panigrahi

I'm experiencing a similar problem and I think it might be a bug 🤔
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.

self.displays = CDisplay.detect_display_devices()
self.no_of_displays = len(self.displays)
self.no_of_connected_dev = self.no_of_displays

Finally, when it reaches the following line, an error is thrown since the self.displayNames comes from ddcutil output not from xrandr.

for i in range(self.no_of_connected_dev):
self.ui.secondary_combo.addItem(self.displayNames[i])
self.ui.primary_combobox.addItem(self.displayNames[i])
pass

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
Copy link
Contributor

@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
Copy link

thardev commented Aug 10, 2024

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
Copy link
Contributor

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
Copy link
Contributor

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

@thardev
Copy link

thardev commented Sep 13, 2024

Hi @Soggy-Pancake

Sorry for the delay, there you go.
Screenshot_20240913_105126

@LordAmit
Copy link
Owner

Hey @Soggy-Pancake - I just wanted to drop by and thank you for looking at this issue!

@Soggy-Pancake
Copy link
Contributor

Soggy-Pancake commented Sep 17, 2024

@thardev I looks like you might be using wayland. Wayland is not currently supported. I have experimental support for wayland in my fork but it is direct backlight control only.

Edit: Nvm they tried to set the laptop display brightness with ddcutil which is not supported. Laptop displays don't use ddc and use an entirely different system for brightness control. You can see the warning your ddcutil detect command. I will add a check to make sure it disables the brightness slider if its a laptop display.

@Soggy-Pancake
Copy link
Contributor

Added message box popups for wayland users as well as an exit condition if they are using wayland and don't have ddcutils since the program would be useless. It shouldn't be able to crash anymore if xrandr is called in wayland since I've wrapped it in a try block as well as the ddcutil set command. Since xrandr is x11 only I've also force enabled ddc mode on wayland.

@thardev
Copy link

thardev commented Sep 18, 2024

Hi @Soggy-Pancake

I've tested your new changes and the app seems to work fine now without ddcutil, I can change the brightness of my monitor without the app crashing. Unfortunately, when I try to enable ddcutil the app crashes on start now. I get the following crash message:
Screenshot_20240918_182252

As per the error message suggests, I will paste here the output of ddcutil detect and xrandr --verbose

ddcutil detect

Display 1
   I2C bus:  /dev/i2c-10
   DRM connector:           card0-DP-1
   EDID synopsis:
      Mfg id:               AUS - UNK
      Model:                VA24DCP
      Product code:         9312  (0x2460)
      Serial number:        N6LMQS147499
      Binary serial number: 16843009 (0x01010101)
      Manufacture year:     2022,  Week: 26
   VCP version:         2.2

xrandr --verbose

Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP connected (normal left inverted right x axis y axis)
        Identifier: 0x52
        Timestamp:  3293122
        Subpixel:   unknown
        Clones:    
        CRTCs:      1 0 2 3
        Transform:  1.000000 0.000000 0.000000
                    0.000000 1.000000 0.000000
                    0.000000 0.000000 1.000000
                   filter: 
        EDID: 
                00ffffffffffff005996013001000000
                1e1c0104a50a0f781600000000000000
                00000000000001000100010001000100
                0100010001000f1b204830002c502014
                02043c3c0000001e000000fc00414e58
                3735333020550a202020000000100000
                00000000000000000000000000000010
                00000000000000000000000000000093
        GAMMA_LUT_SIZE: 4096 
                range: (0, -1)
        DEGAMMA_LUT_SIZE: 4096 
                range: (0, -1)
        GAMMA_LUT: 0 
                range: (0, 65535)
        CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
                0 1 
        DEGAMMA_LUT: 0 
                range: (0, 65535)
        TearFree: auto 
                supported: off, on, auto
        panel orientation: Right Side Up 
                supported: Normal, Upside Down, Left Side Up, Right Side Up
        HDCP Content Type: HDCP Type0 
                supported: HDCP Type0, HDCP Type1
        Content Protection: Undesired 
                supported: Undesired, Desired, Enabled
        vrr_capable: 0 
                range: (0, 1)
        Colorspace: Default 
                supported: Default, BT709_YCC, opRGB, BT2020_RGB, BT2020_YCC
        content type: No Data 
                supported: No Data, Graphics, Photo, Cinema, Game
        abm level: 0 
                range: (0, 4)
        max bpc: 16 
                range: (8, 16)
        underscan vborder: 0 
                range: (0, 128)
        underscan hborder: 0 
                range: (0, 128)
        underscan: off 
                supported: off, on, auto
        scaling mode: None 
                supported: None, Full, Center, Full aspect
        link-status: Good 
                supported: Good, Bad
        CONNECTOR_ID: 111 
                supported: 111
        non-desktop: 0 
                range: (0, 1)
  800x1280 (0x55) 69.270MHz +HSync +VSync +preferred
        h: width   800 start  832 end  852 total  872 skew    0 clock  79.44KHz
        v: height 1280 start 1296 end 1298 total 1324           clock  60.00Hz
  256x160 (0x56)  3.236MHz -HSync +VSync
        h: width   256 start  264 end  288 total  320 skew    0 clock  10.11KHz
        v: height  160 start  163 end  169 total  172           clock  58.79Hz
DisplayPort-0 connected primary 1920x1080+0+0 (0x58) normal (normal left inverted right x axis y axis) 527mm x 296mm
        Identifier: 0x53
        Timestamp:  3293122
        Subpixel:   unknown
        Gamma:      1.0:1.0:1.0
        Brightness: 0.99
        Clones:    
        CRTC:       0
        CRTCs:      1 0 2 3
        Transform:  1.000000 0.000000 0.000000
                    0.000000 1.000000 0.000000
                    0.000000 0.000000 1.000000
                   filter: 
        _KDE_SCREEN_INDEX: 1 
        EDID: 
                00ffffffffffff0006b3602401010101
                1a20010380351f78ea15c5a75650a026
                115054bfef00714f8180814081c09500
                b300d1c0d1cf023a801871382d40582c
                45000f282100001e000000fd00304b1e
                5517000a202020202020000000fc0056
                4132344443500a2020202020000000ff
                004e364c4d51533134373439390a0149
                02032af14b900504030201111213141f
                230907078301000065030c001000681a
                00000101304bf0e2006a3b5680b07238
                324088d035000f282100001c662156aa
                51001e30468f33000f282100001e011d
                007251d01e206e2855000f282100001e
                8c0ad08a20e02d10103e96000f282100
                001800000000000000000000000000bd
        GAMMA_LUT_SIZE: 4096 
                range: (0, -1)
        DEGAMMA_LUT_SIZE: 4096 
                range: (0, -1)
        GAMMA_LUT: 0 
                range: (0, 65535)
        CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
                0 1 
        DEGAMMA_LUT: 0 
                range: (0, 65535)
        TearFree: auto 
                supported: off, on, auto
        subconnector: HDMI 
                supported: Unknown, VGA, DVI-D, HDMI, DP, Wireless, Native
        HDCP Content Type: HDCP Type0 
                supported: HDCP Type0, HDCP Type1
        Content Protection: Undesired 
                supported: Undesired, Desired, Enabled
        vrr_capable: 0 
                range: (0, 1)
        Colorspace: Default 
                supported: Default, BT709_YCC, opRGB, BT2020_RGB, BT2020_YCC
        content type: No Data 
                supported: No Data, Graphics, Photo, Cinema, Game
        max bpc: 16 
                range: (8, 16)
        underscan vborder: 0 
                range: (0, 128)
        underscan hborder: 0 
                range: (0, 128)
        underscan: off 
                supported: off, on, auto
        scaling mode: None 
                supported: None, Full, Center, Full aspect
        link-status: Good 
                supported: Good, Bad
        CONNECTOR_ID: 121 
                supported: 121
        non-desktop: 0 
                range: (0, 1)
  1920x1080 (0x57) 148.500MHz +HSync +VSync +preferred
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.50KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  60.00Hz
  1920x1080 (0x58) 220.750MHz -HSync +VSync *current
        h: width  1920 start 2056 end 2264 total 2608 skew    0 clock  84.64KHz
        v: height 1080 start 1083 end 1088 total 1130           clock  74.91Hz
  1920x1080 (0x59) 148.500MHz +HSync +VSync
        h: width  1920 start 2448 end 2492 total 2640 skew    0 clock  56.25KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  50.00Hz
  1920x1080 (0x5a) 148.352MHz +HSync +VSync
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.43KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  59.94Hz
  1680x1050 (0x5b) 119.000MHz +HSync -VSync
        h: width  1680 start 1728 end 1760 total 1840 skew    0 clock  64.67KHz
        v: height 1050 start 1053 end 1059 total 1080           clock  59.88Hz
  1280x1024 (0x5c) 135.000MHz +HSync +VSync
        h: width  1280 start 1296 end 1440 total 1688 skew    0 clock  79.98KHz
        v: height 1024 start 1025 end 1028 total 1066           clock  75.02Hz
  1280x1024 (0x5d) 108.000MHz +HSync +VSync
        h: width  1280 start 1328 end 1440 total 1688 skew    0 clock  63.98KHz
        v: height 1024 start 1025 end 1028 total 1066           clock  60.02Hz
  1440x900 (0x5e) 88.750MHz +HSync -VSync
        h: width  1440 start 1488 end 1520 total 1600 skew    0 clock  55.47KHz
        v: height  900 start  903 end  909 total  926           clock  59.90Hz
  1280x960 (0x5f) 108.000MHz +HSync +VSync
        h: width  1280 start 1376 end 1488 total 1800 skew    0 clock  60.00KHz
        v: height  960 start  961 end  964 total 1000           clock  60.00Hz
  1366x768 (0x60) 85.500MHz +HSync +VSync
        h: width  1366 start 1436 end 1579 total 1792 skew    0 clock  47.71KHz
        v: height  768 start  771 end  774 total  798           clock  59.79Hz
  1280x800 (0x61) 148.500MHz +HSync +VSync
        h: width  1280 start 2008 end 2052 total 2200 skew    0 clock  67.50KHz
        v: height  800 start 1084 end 1089 total 1125           clock  60.00Hz
  1152x864 (0x62) 108.000MHz +HSync +VSync
        h: width  1152 start 1216 end 1344 total 1600 skew    0 clock  67.50KHz
        v: height  864 start  865 end  868 total  900           clock  75.00Hz
  1280x720 (0x63) 74.250MHz +HSync +VSync
        h: width  1280 start 1390 end 1430 total 1650 skew    0 clock  45.00KHz
        v: height  720 start  725 end  730 total  750           clock  60.00Hz
  1280x720 (0x64) 74.250MHz +HSync +VSync
        h: width  1280 start 1720 end 1760 total 1980 skew    0 clock  37.50KHz
        v: height  720 start  725 end  730 total  750           clock  50.00Hz
  1280x720 (0x65) 74.176MHz +HSync +VSync
        h: width  1280 start 1390 end 1430 total 1650 skew    0 clock  44.96KHz
        v: height  720 start  725 end  730 total  750           clock  59.94Hz
  1024x768 (0x66) 78.750MHz +HSync +VSync
        h: width  1024 start 1040 end 1136 total 1312 skew    0 clock  60.02KHz
        v: height  768 start  769 end  772 total  800           clock  75.03Hz
  1024x768 (0x67) 75.000MHz -HSync -VSync
        h: width  1024 start 1048 end 1184 total 1328 skew    0 clock  56.48KHz
        v: height  768 start  771 end  777 total  806           clock  70.07Hz
  1024x768 (0x68) 65.000MHz -HSync -VSync
        h: width  1024 start 1048 end 1184 total 1344 skew    0 clock  48.36KHz
        v: height  768 start  771 end  777 total  806           clock  60.00Hz
  832x624 (0x69) 57.284MHz -HSync -VSync
        h: width   832 start  864 end  928 total 1152 skew    0 clock  49.73KHz
        v: height  624 start  625 end  628 total  667           clock  74.55Hz
  800x600 (0x6a) 50.000MHz +HSync +VSync
        h: width   800 start  856 end  976 total 1040 skew    0 clock  48.08KHz
        v: height  600 start  637 end  643 total  666           clock  72.19Hz
  800x600 (0x6b) 49.500MHz +HSync +VSync
        h: width   800 start  816 end  896 total 1056 skew    0 clock  46.88KHz
        v: height  600 start  601 end  604 total  625           clock  75.00Hz
  800x600 (0x6c) 40.000MHz +HSync +VSync
        h: width   800 start  840 end  968 total 1056 skew    0 clock  37.88KHz
        v: height  600 start  601 end  605 total  628           clock  60.32Hz
  800x600 (0x6d) 36.000MHz +HSync +VSync
        h: width   800 start  824 end  896 total 1024 skew    0 clock  35.16KHz
        v: height  600 start  601 end  603 total  625           clock  56.25Hz
  720x576 (0x6e) 27.000MHz -HSync -VSync
        h: width   720 start  732 end  796 total  864 skew    0 clock  31.25KHz
        v: height  576 start  581 end  586 total  625           clock  50.00Hz
  720x480 (0x6f) 27.027MHz -HSync -VSync
        h: width   720 start  736 end  798 total  858 skew    0 clock  31.50KHz
        v: height  480 start  489 end  495 total  525           clock  60.00Hz
  720x480 (0x70) 27.000MHz -HSync -VSync
        h: width   720 start  736 end  798 total  858 skew    0 clock  31.47KHz
        v: height  480 start  489 end  495 total  525           clock  59.94Hz
  640x480 (0x71) 31.500MHz -HSync -VSync
        h: width   640 start  656 end  720 total  840 skew    0 clock  37.50KHz
        v: height  480 start  481 end  484 total  500           clock  75.00Hz
  640x480 (0x72) 31.500MHz -HSync -VSync
        h: width   640 start  664 end  704 total  832 skew    0 clock  37.86KHz
        v: height  480 start  489 end  492 total  520           clock  72.81Hz
  640x480 (0x73) 30.240MHz -HSync -VSync
        h: width   640 start  704 end  768 total  864 skew    0 clock  35.00KHz
        v: height  480 start  483 end  486 total  525           clock  66.67Hz
  640x480 (0x74) 25.200MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.50KHz
        v: height  480 start  490 end  492 total  525           clock  60.00Hz
  640x480 (0x75) 25.175MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
        v: height  480 start  490 end  492 total  525           clock  59.94Hz
  720x400 (0x76) 28.320MHz -HSync +VSync
        h: width   720 start  738 end  846 total  900 skew    0 clock  31.47KHz
        v: height  400 start  412 end  414 total  449           clock  70.08Hz

Thanks a lot for your help and your work!

@Soggy-Pancake
Copy link
Contributor

Soggy-Pancake commented Sep 22, 2024

@thardev is there any chance we could get in a discord call? Currently working on adding a lot of logging so commands don't need to be copied into reports anymore as well as showing the exact input everything is getting. I also changed the command that raised an exception to getOutput so it ignores the process return value.

discord is Soggy_Pancake

Preview of what the logs look like:
image

@thardev
Copy link

thardev commented Oct 31, 2024

Hi @Soggy-Pancake

I think yes, we could, sorry for the late response but I'm a bit busy recently.
Let me know, when it could fit for you and we try to do this call.

@Soggy-Pancake
Copy link
Contributor

Nice, my time zone is mountain standard time. Discord is @ soggy_pancake. Lmk what ur handle is through here when you send the friend request so I know its you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants