davidhi7 / ddcci-plasmoid

KDE Plasma widget to adjust the brightness of multiple external monitors
MIT License
390 stars 11 forks source link

ddcci_plasmoid_backend detect fails due to ddcutil output #69

Open cemkaya-mpi opened 4 months ago

cemkaya-mpi commented 4 months ago

Hello,

ddcci_plasmoid_backend detect fails for me with ddcutil version 2.1.3, since the output of ddcutil getvcp --bus ** --brief ** is

Unable to open directory /sys/devices/pci0000:00/0000:00:01.1/0000:01:00.0/drm: No such file or directory
VCP 10 C 100 100

I believe this is due to the error message in the first line.

I modified

result = await async_subprocess_wrapper(
            f'ddcutil getvcp --bus {bus_id} --brief {brightness_feature_code:x}')

in the detect() function in ddcci.py for the time being and added | sed -n 2p to remove the error message, after which everything works as expected. Let me know if you need more information.

Sollace commented 1 month ago

I still get an error after adding those, however I can tell it's better.

Note also I had to change line 109 from this:

        except subprocess.CalledProcessError as err:
            monitor_data.append(err)

To

        except CalledProcessError as err:
            monitor_data.append(err)

As otherwise the script fails in a different way image

Sollace commented 1 month ago

After some fiddling with print statements, I was able to get it working eventually with the updated version. Instead of the above, I had to add to strip_ddcutil_warnings on line 160

    # Fix #69
    stdout = stdout.replace(
        "Unable to open directory /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm: No such file or directory\n",
        "",
    )

Could probably do better by using some sort of regex but I don't really know how to do that in python.