kfix / ddcctl

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

Error: Failed to parse WindowServer's preferences #92

Open detlefs opened 3 years ago

detlefs commented 3 years ago

Running the tool I get the following output:

sudo ./ddcctl -d 1 -i 17                                                                                                                             
D: CGDisplay 51EAD488-736E-344F-3D19-FC1626C9B248 dispID(#1) (3440x1440 0°) 109.00 DPI
I: found 1 external display
E: Failed to parse WindowServer's preferences! (/Library/Preferences/com.apple.windowserver.plist)
I: polling EDID for #1 (ID 1 => (null))
E: Failed to poll display!

I'm using a M1 Mac mini with macOS Big Sur (11.1) I downloaded the latest release of the tool.

I couldn't find a file /Library/Preferences/com.apple.windowserver.plist on my system, but a file /Library/Preferences/com.apple.windowserver.displays.plist. Maybe the name was changed for Big Sur?

Running it with -h option, I get the following result:

sudo ./ddcctl -h                                                                                                                                     
D: CGDisplay 51EAD488-736E-344F-3D19-FC1626C9B248 dispID(#1) (3440x1440 0°) 109.00 DPI
I: found 1 external display
2021-01-20 11:28:45.833 ddcctl[27476:1447428] ddcctl 0.1x - Usage:
...
madebyfabian commented 3 years ago

Same issue here on Mac Mini M1 2020, MacOS Big Sur 11.1.

I'm not a native development expert, but for me, it looks like the reason for this is this hardcoded string in there:

https://github.com/kfix/ddcctl/blob/72c1f3413776b3758177d104ae92cf22ce410aac/src/ddcctl.m#L50

wich either should be a system variable, or, if no system variable exists, it should search check which macos version is being used and then decide which path it should take.

I will try to build it my own and if it works, I post the results in here.

kmplngj commented 3 years ago

Is this fixable without a new release version?

detlefs commented 3 years ago

It seems to be not only the filename. It seems that com.apple.windowserver.displays.plist doesn't contain the structure/values required by the function. There is no DisplayID or IODisplayLocation in my file. I think it's necessary to find a new way to determine the display device location value

tslater commented 3 years ago

In line with what you said, @detlefs, I symlinked the plist file to the old path and now I'm getting this error:

D: CGDisplay 166D886F-5A17-0E35-0857-D6964E3302DB dispID(#2) (3840x2160 0°) 139.00 DPI
I: found 1 external display
2021-05-12 12:55:43.827 ddcctl[32394:966897] -[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0xb3e44e1fb7bdd192
2021-05-12 12:55:43.827 ddcctl[32394:966897] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0xb3e44e1fb7bdd192'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000018640e320 __exceptionPreprocess + 240
    1   libobjc.A.dylib                     0x000000018613cc04 objc_exception_throw + 60
    2   CoreFoundation                      0x000000018649d020 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x0000000186370184 ___forwarding___ + 1444
    4   CoreFoundation                      0x000000018636fb30 _CF_forwarding_prep_0 + 96
    5   ddcctl                              0x00000001029097e0 getDisplayDeviceLocation + 280
    6   ddcctl                              0x000000010290a9ec main + 3368
    7   libdyld.dylib                       0x00000001862b1f34 start + 4
)
libc++abi.dylib: terminating with uncaught exception of type NSException

So it looks like the problem is deeper...a bit beyond me...

coriolanweihrauch commented 3 years ago

Seems to be a sub-issue of #86

kfix commented 3 years ago

I think I'm gonna rip this stuff out.

FWIW, the 1st part of it (file finding) works on my Catalina -> Big Sur MacBook, which doesn't have the .displays.plist file being mentioned.

yellowmegaman commented 1 year ago

Same here on m1 Air running Monterey. I do have /Library/Preferences/com.apple.windowserver.displays.plist file, but not the /Library/Preferences/com.apple.windowserver.plist

Tried to create a symlink, to no avail:

➜  ~ ddcctl -d 1 -b 90
D: CGDisplay EE5E12D7-D9C0-0B13-0857-D6964E3302DB dispID(#2) (2560x1440 0°) HiDPI
I: found 1 external display
2022-09-20 12:36:03.836 ddcctl[19646:15501860] -[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x8af6716c9b7372ed
2022-09-20 12:36:03.841 ddcctl[19646:15501860] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x8af6716c9b7372ed'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001b9125198 __exceptionPreprocess + 240
    1   libobjc.A.dylib                     0x00000001b8e6fe04 objc_exception_throw + 60
    2   CoreFoundation                      0x00000001b91b8f40 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00000001b9084544 ___forwarding___ + 1764
    4   CoreFoundation                      0x00000001b9083da0 _CF_forwarding_prep_0 + 96
    5   ddcctl                              0x0000000102ba9b8c getDisplayDeviceLocation + 272
    6   ddcctl                              0x0000000102baabfc main + 2952
    7   dyld                                0x0000000102d5908c start + 520
)
libc++abi: terminating with uncaught exception of type NSException
[1]    19646 abort      ddcctl -d 1 -b 90
➜  ~
BurpedUpChunks commented 1 year ago

FWIW, this works fine on my 2018 intel mac mini, which has the com.apple.windowserver.plist file.

ddcctl -d 1 D: CGDisplay 5C9147A3-EDE9-AC8E-ECD5-BCFB6DD77685 dispID(#458658526) (2560x1440 0°) HiDPI I: found 1 external display I: polling EDID for #1 (ID 458658526 => IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/IGPU@2/AppleIntelFramebuffer@2) I: got edid.name: LG ULTRAFINE I: got edid.serial: 102NTSUJ3070

It does not work on my mini M2 Pro, which has the com.apple.windowserver.displays.plist file.

ddcctl -d 1
D: CGDisplay 4643CDD0-144E-44E7-B7BC-3A19BCF36B13 dispID(#1) (3840x2160 0°) 139.00 DPI D: CGDisplay 030C44D6-5FEA-44DA-93B7-64CCBCE49A5F dispID(#2) (1440x2560 90°) 122.00 DPI D: CGDisplay 61D730EA-95CB-41AE-BB6A-0D157400A71B dispID(#3) (1440x2560 90°) 122.00 DPI I: found 3 external displays E: Failed to parse WindowServer's preferences! (/Library/Preferences/com.apple.windowserver.plist) E: Failed to acquire framebuffer device for display

dchimeno commented 11 months ago

Same error here, mac book pro 13 m1:

ddcctl -d 1

D: CGDisplay BCD9991B-F48F-8EC0-0857-D6964E3302DB dispID(#2) (1920x1080 0°) 92.00 DPI
I: found 1 external display
E: Failed to parse WindowServer's preferences! (/Library/Preferences/com.apple.windowserver.plist)
E: Failed to acquire framebuffer device for display
lambda-m commented 7 months ago

Same here... M3 with Sonoma 14.3

% ddcctl -d 1
D: CGDisplay 57B2273F-7EE4-4CFF-A898-FFFEF81C3EC8 dispID(#4) (3840x1600 0°) 111.00 DPI
I: found 1 external display
E: Failed to parse WindowServer's preferences! (/Library/Preferences/com.apple.windowserver.plist)
E: Failed to acquire framebuffer device for display
denisidoro commented 6 months ago

Any ETAs for fixing this? It seems like ddcctl doesn't work with ARM chips

denisidoro commented 6 months ago

I created a symlink by running the following:

sudo ln -s /Library/Preferences/com.apple.windowserver.displays.plist /Library/Preferences/com.apple.windowserver.plist

However, now I get this:

❯ ddcctl -d 1 -b 100 -c 100 -p 1

D: CGDisplay 5578120E-96C8-400C-B72F-74B384F0EEFE dispID(#3) (1920x1080 0°) 92.00 DPI
I: found 1 external display
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0xb78938e1db1e0232'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000186e7c540 __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x000000018696deb4 objc_exception_throw + 60
    2   CoreFoundation                      0x0000000186f2e124 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x0000000186de6764 ___forwarding___ + 1572
    4   CoreFoundation                      0x0000000186de6080 _CF_forwarding_prep_0 + 96
    5   ddcctl                              0x000000010260da78 getDisplayDeviceLocation + 228
    6   ddcctl                              0x000000010260e83c main + 2512
    7   dyld                                0x00000001869a90e0 start + 2360
)
libc++abi: terminating due to uncaught exception of type NSException
/Users/denis.isidoro/dotfiles/scripts/system/display: line 31: 66322 Abort trap: 6           "${args[@]}"
BurpedUpChunks commented 6 months ago

denisidoro, I got the same kind of error. I assume the new file has a different format than the old one.

Dentrax commented 4 months ago

M1 Max with Sonoma 14.4 user here. Fresh installed this app and throws the following error:

D: CGDisplay BEF45B94-B0AA-484F-B002-220869C71ADA dispID(#4) (1920x1080 0°) 92.00 DPI
I: found 1 external display
E: Failed to parse WindowServer's preferences! (/Library/Preferences/com.apple.windowserver.plist)
E: Failed to acquire framebuffer device for display

I think thats because I don't have /Library/Preferences/com.apple.windowserver.plist file:

stat /Library/Preferences/com.apple.windowserver.plist
gstat: cannot stat '/Library/Preferences/com.apple.windowserver.plist': No such file or directory

It seems its hardcoded here: https://github.com/kfix/ddcctl/blob/06c7ab6eba5b1c903678f8113a92cef990acaf90/src/ddcctl.m#L48

Ran the following command:

sudo ln ~/Library/Preferences/ByHost/com.apple.windowserver.displays.1055DC8F-47D8-5E93-8E9A-12E9658B43FB.plist /Library/Preferences/com.apple.windowserver.plist

Then I hit:

E: Failed to get 'DisplayAnyUserSets' key from WindowServer's preferences! (/Library/Preferences/com.apple.windowserver.plist)

This also results panic: (As @denisidoro pointed out above)

sudo ln -s /Library/Preferences/com.apple.windowserver.displays.plist /Library/Preferences/com.apple.windowserver.plist
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0xa180ac6828bca08a'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001935ceccc __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x00000001930b6788 objc_exception_throw + 60
    2   CoreFoundation                      0x000000019368102c -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x0000000193538cdc ___forwarding___ + 1580
    4   CoreFoundation                      0x00000001935385f0 _CF_forwarding_prep_0 + 96
    5   ddcctl                              0x0000000104439a78 getDisplayDeviceLocation + 228
    6   ddcctl                              0x000000010443a83c main + 2512
    7   dyld                                0x00000001930f20e0 start + 2360
)
libc++abi: terminating due to uncaught exception of type NSException

I found some example data to replace my own file but just don't wanted to mess the configs: https://forums.macrumors.com/threads/m1-mac-external-display-fuzzy-fonts-colors-ypbpr-vs-rgb.2276345/page-28?post=30550735#post-30550735

Is there any other place to get IODisplayLocation? https://github.com/kfix/ddcctl/blob/06c7ab6eba5b1c903678f8113a92cef990acaf90/src/ddcctl.m#L69C47-L69C64

/cc @kfix

Contraboi commented 1 month ago

@Dentrax I have the exact same issue. Have you found a solution?

Dentrax commented 1 month ago

@Dentrax I have the exact same issue. Have you found a solution?

@Contraboi sorry, unfortunately haven't. So I've switched to https://github.com/waydabber/m1ddc - works like a charm, no issues at all.