kfix / ddcctl

DDC monitor controls (brightness) for Mac OSX command line
GNU General Public License v3.0
1.84k stars 151 forks source link

Address monitors by edid.name or edid.serial instead of display number #85

Open christophberger opened 3 years ago

christophberger commented 3 years ago

Hi,

First of all, this project is awesome and saves me a lot of daily hassle. I use two different external monitors on a Macbook, and one of them cannot remember its brightness. ddcctl, together with some automation, reminds the monitor to brighten up :)

However, every once in a while, when the Mac wakes up, it flips the display numbers. The monitor that used to be no. 1 is now no. 2 and vice versa. When this happens, any script of the form ddcctl -d <number> accesses the wrong monitor.

So it would be great if ddcctl gets an option for addressing monitors by their edid.name or edid.serial value, rather than their (volatile) display number.

Examples: ddcctl -d 9X2VY5C410UL (passing edid.serial) ddcctl -d "DELL U2515H" (passing edid.name)

I haven't touched ObjC or Apple libraries/API's since a decade or so, hence I am not in the best position to contribute a PR, but maybe someone else can?

christophberger commented 3 years ago

Workaround found:

Sample function for the Fish shell:

function bright
    set monitor (ddcctl -d 1 -b '?' | awk 'BEGIN{ FS=": "} /edid.name/{ print $3 }')
    if test $monitor = "IPS1506UHDR"
        set display 1
    else
        set display 2
    end
    ddcctl -d $display -b 38 
end

Would be awesome to have sth like ddcctl -d "IPS1506UHDR" -b 38 as a solution

kfix commented 3 years ago

there's a couple of PRs I want to get merged first, but we could support a string expression.

You seem to be lucky in that your Dell has a serial number, but who knows how unique that really is with another Dell of the same model.

there's also some chatter about how we could grab a persistent GUID for a particular display: https://stackoverflow.com/a/48450870.

If that really holds up across reboots and incorporates Model-Vendor-Serial, using those UUID's might be the way to go.

christophberger commented 3 years ago

I have only one Dell, the other display is a different brand, so for me there is no risk of identical serial numbers. But I see the point. Let's hope the persistent GUID's have all properties required to solve the problem.