Skip to content

Instantly share code, notes, and snippets.

@GetVladimir
Last active July 5, 2024 07:14
Show Gist options
  • Save GetVladimir/c89a26df1806001543bef4c8d90cc2f8 to your computer and use it in GitHub Desktop.
Save GetVladimir/c89a26df1806001543bef4c8d90cc2f8 to your computer and use it in GitHub Desktop.
Force RGB Color on M1 Mac

Force RGB Color on M1 Mac

How to Force RGB Color Output instead of YPbPr on your M1 Apple Silicon Mac for an External Monitor.

This step-by-step video tutorial will guide you through the procedure of forcing RGB color output on your M1 Mac.

Force RGB Color on M1 Mac

Here is the direct link to the video tutorial: https://www.youtube.com/watch?v=Z1EqH3fd0V4

The video also has Closed Captions (Subtitles) that you can enable, to make it easier to follow if needed.



Please note that you're doing any changes on your own risk.

Terminal commands used in the video

Here are each of the Terminal commands mentioned in the tutorial, so that you can just copy and paste them:

open /Library/Preferences

plutil -convert xml1

plutil -convert binary1

plutil -lint



The step-by-step procedure on how to force RGB Color Output on M1 and M2 based Macs with Terminal commands

  1. Open Terminal and use this command to make Finder select the displays plist file:
    open -R /Library/Preferences/com.apple.windowserver.displays.plist

  2. Drag and drop the com.apple.windowserver.displays.plist file to Desktop manually. Don't use the cp command, as it won't add your current user with writing privileges.

  3. Convert the file to XML:
    plutil -convert xml1 ~/Desktop/com.apple.windowserver.displays.plist

  4. Open the converted file with the default plain text editor (avoid using the built-in TextEdit app if possible, since it might modify the file and make it unreadable by the system)
    open -t ~/Desktop/com.apple.windowserver.displays.plist
    or
    open -a CotEditor.app ~/Desktop/com.apple.windowserver.displays.plist

  5. Copy and paste the missing LinkDesription Key under the current display (check the screenshot below for an example of how it should look like):

				<key>LinkDescription</key>
				<dict>
					<key>BitDepth</key>
					<integer>8</integer>
					<key>EOTF</key>
					<integer>0</integer>
					<key>PixelEncoding</key>
					<integer>0</integer>
					<key>Range</key>
					<integer>1</integer>
				</dict>
  1. Save the file and then convert it to binary again:
    plutil -convert binary1 ~/Desktop/com.apple.windowserver.displays.plist

  2. Check if the plist file is valid:
    plutil -lint ~/Desktop/com.apple.windowserver.displays.plist

  3. Open the /Library/Preferences/ folder again:
    open /Library/Preferences/

  4. Drag and drop the updated com.apple.windowserver.displays.plist file from Desktop to the Library folder manually. Don't use the cp command, as it won't add your current user with writing privileges.

  5. Right Click on the com.apple.windowserver.displays.plist file in the Library folder and click on Get Info

  6. Check the boxes for Stationery and Locked.

  7. Reboot the Mac.

That's it!



(Alternative) Terminal commands to force RGB Color Output on M1 and M2 based Macs and workaround for losing RGB color after waking up from sleep

  1. Open Terminal

  2. Paste the following commands to edit the User's displays plist file com.apple.windowserver.displays.[UUID].plist using the built-in PlistBuddy function in macOS:

/usr/libexec/PlistBuddy -c "add DisplaySets:Configs:DisplayConfig:DisplayConfig:DisplayConfig:LinkDescription:BitDepth integer" ~/Library/Preferences/ByHost/com.apple.windowserver.displays.*.plist
/usr/libexec/PlistBuddy -c "set DisplaySets:Configs:DisplayConfig:DisplayConfig:DisplayConfig:LinkDescription:BitDepth 8" ~/Library/Preferences/ByHost/com.apple.windowserver.displays.*.plist
/usr/libexec/PlistBuddy -c "add DisplaySets:Configs:DisplayConfig:DisplayConfig:DisplayConfig:LinkDescription:EOTF integer" ~/Library/Preferences/ByHost/com.apple.windowserver.displays.*.plist
/usr/libexec/PlistBuddy -c "add DisplaySets:Configs:DisplayConfig:DisplayConfig:DisplayConfig:LinkDescription:PixelEncoding integer" ~/Library/Preferences/ByHost/com.apple.windowserver.displays.*.plist
/usr/libexec/PlistBuddy -c "add DisplaySets:Configs:DisplayConfig:DisplayConfig:DisplayConfig:LinkDescription:Range integer" ~/Library/Preferences/ByHost/com.apple.windowserver.displays.*.plist
  1. Reboot your Mac

(Workaround) If your Mac loses RGB color after waking up from sleep mode, either Reboot your Mac (recommended) or use this Terminal command to stop the WindowServer and login again (not recommended):

sudo killall -HUP WindowServer



End result

The end result is having your M1 mac output RGB color to your external monitor instead of YPbPr, potentially making the colors more accurate and the text a bit more crisp, even on older 1080p monitors.

Hopefully this tutorial would be useful to someone.

Please feel free to ask in the comment section if you have any questions regarding this procedure.



Background

While doing a lot of testing on how the Dual-Cable workaround makes RGB to work on M1, I've discovered what changes it makes to macOS, and managed to create a more streamlined workaround without the need to use a second cable.

To make things easier, I've created a step-by-step video tutorial of the whole procedure that should force RGB color output on your M1 Mac connected to an external monitor, and works on an HDMI-to-HDMI cable connection.

Credits

Big thanks goes to the amazing community and all their help over the years to solve issues like this:
https://gist.github.com/ejdyksen/8302862
https://gist.github.com/adaugherity/7435890

Useful Sources

Apple Open Source Project Files for Displays and Graphics
https://opensource.apple.com/source/IOKitUser/IOKitUser-1445.60.1/graphics.subproj/IODisplayLib.c
https://opensource.apple.com/source/IOGraphics/IOGraphics-517.17/IOGraphicsFamily/IOFramebuffer.cpp.auto.html

How to Edit and Convert binary plist files
http://hints.macworld.com/article.php?story=20050803111126899
https://apple.stackexchange.com/questions/155393/how-to-beautify-binary-dict-files
https://discussions.apple.com/thread/1768480

How to Edit plist files using defaults and PlistBuddy
https://ss64.com/osx/defaults.html
https://github.com/mathiasbynens/dotfiles/blob/master/.macos

Apps based on this method

@sudowork has created an awesome script written in Phyton that automates the steps and checks for duplicate files.
You can find more info about it here: https://github.com/sudowork/fix_m1_rgb

@dangh has created an alernative script for fishshell.
You can find more info about it here: https://github.com/dangh/force-rgb.fish

@GetVladimir I've also created a Shortcut to Force RGB Color Output using the built-in Shortcuts app.
You can find how to create the Shortcut here: https://gist.github.com/GetVladimir/c89a26df1806001543bef4c8d90cc2f8?permalink_comment_id=4531552#gistcomment-4531552

@entropyconquers has created a script based on this method written in Phyton that automates the steps, makes a backup and checks for duplicate files.
You can find more info about it here: https://github.com/entropyconquers/Force-RGB-Color-on-M1-M2-Mac-Script

Additional notes

Multiple PixelEncoding and Range keys in the same plist file
Note that there might be multiple instances of the PixelEncoding and Range keys in the same file, one for each output of your monitor and for different AirPlay devices. You might need to update the integer on each one to get RGB color output on all displays.

Getting RGB color only before login
There might be multiple duplicate plist files with the same name in different locations.

Make sure that you only have the main modified file in:
/Library/Preferences

Then make a backup and remove duplicate displays plist files from these locations (if any):
~/Library/Preferences
or
/Users/username/Library/Preferences
and
/Users/username/Library/Preferences/ByHost


Please note that you'll need to have administrator privileges in order to modify the file in /Library/Preferences. Thanks goes to @keegandent and @StrategicalIT for pointing this out.

Updates regarding macOS Monterey

USB-C to DisplayPort
From what I've seen, it seems that macOS Monterey 12.0.1 finally outputs RGB color by default on some monitors when using USB-C to DisplayPort cable on M1 Apple Silicone Macs.

You might need to make a backup and delete these 2 files:
/Library/Preferences/com.apple.windowserver.displays.plist
and
/Users/yourname/Library/Preferences/ByHost/com.apple.windowserver.displays.[UDID].plist

Restart your Mac and it should properly output RGB color on the monitor on the next boot.

HDMI to HDMI
The situation with HDMI seems to got a bit more complicated. Now the whole section for the LinkDescription might be missing from the com.apple.windowserver.displays.plist on a clean install and doesn't seem to be recreated when rotating the screen either.

Luckily, the solution still works, but you might need to manually add this whole section in the displays plist file:

					<key>LinkDescription</key>
					<dict>
						<key>BitDepth</key>
						<integer>8</integer>
						<key>EOTF</key>
						<integer>0</integer>
						<key>PixelEncoding</key>
						<integer>0</integer>
						<key>Range</key>
						<integer>1</integer>
					</dict>



The section usually goes right under the CurrentInfo key, and it should look something like this:

pixelencoding

This should get your RGB color output working on M1 Mac mini, even when connected with HDMI to HDMI cable.

Multiple monitors when one them is using HDMI to HDMI
Additional thanks goes to @somogyi-ede who tested this with multiple monitors and confirmed that the LinkDescription key needs to be added under each monitor instance in order for all of them to receive RGB color output. Link to the comment

Updates regarding macOS 13 Ventura

USB-C to DisplayPort
The macOS 13 Ventura beta seems to outputs RGB color by default on some monitors when using USB-C to DisplayPort cable on M1 Apple Silicone Macs.

You might need to make a backup and delete these 2 files:
/Library/Preferences/com.apple.windowserver.displays.plist
and
/Users/yourname/Library/Preferences/ByHost/com.apple.windowserver.displays.[UDID].plist

Restart your Mac and it should properly output RGB color on the monitor on the next boot.

HDMI to HDMI
Similar as macOS Monterey, the situation with HDMI on macOS Venturs seems a bit more complicated. Usually the whole section for the LinkDescription might be missing from the com.apple.windowserver.displays.plist on a clean install and doesn't seem to be recreated when rotating the screen either.

Luckily, the solution still works, and you still need to manually add this whole section in the displays plist file:

					<key>LinkDescription</key>
					<dict>
						<key>BitDepth</key>
						<integer>8</integer>
						<key>EOTF</key>
						<integer>0</integer>
						<key>PixelEncoding</key>
						<integer>0</integer>
						<key>Range</key>
						<integer>1</integer>
					</dict>



The section usually goes right under the CurrentInfo key, and it should look something like this:

pixelencoding

This should get your RGB color output working on M1 Mac mini, even when connected with HDMI to HDMI cable.

(Optional) Lock the plist file and set it as stationary
After the macOS Ventura 13.3 update, the plist file seems to get overwritten on reboot.

After you make the edits in the file, you can try setting the file /Library/Preferences/com.apple.windowserver.displays.plist as Stationery pad and Locked, so that it doesn't get overwritten on every reboot

Stationery Pad Locked

To do this, right click on the plist file, click on Get Info and check the boxes next to Stationery pad and Locked

This requires further testing and might cause some issues, like not being able to remember new resolutions or display settings. Please note that you're making any changes at your own risk.

Updates regarding macOS 14 Sonoma Beta

USB-C to DisplayPort
The macOS 14 Sonoma seems to outputs RGB color by default when using USB-C to DisplayPort cable.

HDMI to HDMI
The macOS 14 Sonoma seems to outputs YCbCr color by default when using HDMI to HDMI cable.

  • Forcing RGB Color Output still seems to work with the original procedure of modifying the plist files

  • Modifying the display plist files still works with the alternative version

  • After the plist files are modified, putting the Mac to sleep and waking it, it seem to keep the RGB Color output (this seems to be fixed at least on a M1 Mac mini)

If you have any additional questions, please feel free to contact me.

@GetVladimir
Copy link
Author

@TerminalWitchcraft you can try and modify the display plist file and choose 10bit color and HDR.

However, if the bandwidth limitations are reached or there is something else not compatible, most of the time HDR runs on YCbCr anyway.

That being said, the macOS interface doesn't really fully support HDR and you'll most likely have better experience just using SDR in most cases.

@dhensen
Copy link

dhensen commented Jun 25, 2024

First of all @GetVladimir and all others, thanks for all the hard work in this gist!!!

Even though, nothing on this page works for me.

I'm on an M3 Pro Sonoma 14.4.1 (23E224) with an LG 38WN95CP external monitor (1350 euro monitor), everything looks slightly blurry, my eyes start to hurt. (since february, Intel MBP 2018 displays sharp)

(I have a Dell dock, but I'm keeping that out of the equation when talking here... first let's get it running without any dock involved)

All my other hardware can render perfectly sharp, but not the 3500 euro M3 Pro (3 thinkpads, 3 desktops, intel MBP 2018).

I've tried, in this order:

  • Bought, installed and messed around with BetterDisplay (this seems totally unrelated, but I'm a linux guy, so what do I know)
  • manually editing the plist files
  • running https://github.com/entropyconquers/Force-RGB-Color-on-M1-M2-Mac-Script
    • it looks like LinkDescription can not be found anywhere anymore, you recognize this?
  • running https://github.com/sudowork/fix_m1_rgb
    • modified this script so it would run on my machine
    • it looks like LinkDescription can not be found anywhere anymore, you recognize this?
  • USB-C to DisplayPort cable (deleted plist and rebooted, tried several times)

I've submitted feedback to Apple.

Spent near to 5K EUR, but can't it sharp with this combi. I can't return either one of these pieces of hardware.

Could this be also be an LG issue? I have no way of checking if my monitor is in RGB or YPBPR mode.

Any other ideas?

@GetVladimir
Copy link
Author

@dhensen thank you for your comment and for the details regarding the monitor and what you've tried.

I've checked the monitor specifications and it seems to be a 3840x1600 144Hz HDR monitor. While the issue is still with the M3 Pro, this combination of the monitor makes it specifically difficult to get it running properly on it.

The monitor is 38" Ultrawide, but the resolution is low that it won't qualify to get retina resolutions working on it. Since macOS doesn't scale properly and doesn't have full fractional scaling support on M3 based Macs, it would look not sharp most of the time.

The best results you can try to get is to use the USB-C to DisplayPort port cable that you already got and remove any modifications and 3rd party apps and scripts that you've added.

After that, go to the built-in monitor settings and turn off HDR and the high refresh rate. Your goal would be to get it running at the native resolution at 60Hz without HDR. Make sure to check for any High Bandwidth or High Resolutions in the settings.

This should get you the best image on that specific monitor with the M3. Please note that the text will not look as sharp as it should

@Amritus
Copy link

Amritus commented Jun 25, 2024

I have a peculiar issue.
Macbook M3 Max, Sonoma 14.5. can't get HDMI to work nor with dual cable solution either.

However, when I use the USB-C -> DP it works on login screen, but not after login, then it changes to YCbCr.
I also have another USB-C -> DP and it doesn't work at all even though it does find the screen.

@GetVladimir
Copy link
Author

@Amritus Thank you for your comment. Something seems strange after the login screen.

If you can, try creating a new temporary user and use the USB-C to DisplayPort cable. Reboot the Mac and login to the temporary users.

If everything looks good on the temporary user, then there is some leftover setting on the main user that needs to be found

@Amritus
Copy link

Amritus commented Jun 26, 2024

@GetVladimir New user and rebooting doesn't work. New Belkin USB-C -> DP cable still showing off colors.

Also, only way to get correct colors before login is to do your fix, reboot and then at login screen colors are correct. But only then and only once. After login colors are off and after reboot also not correct colors at login screen.

@GetVladimir
Copy link
Author

@Amritus thank you for the update. Glad that it works at least with the workaround.

Try to lock the display plist file from changes to see if that makes any difference. You can check how to lock it in the guide on the top

@Amritus
Copy link

Amritus commented Jun 26, 2024

@GetVladimir Ok, so I just tried with your solution, and tested HDMI. Works the same, only once, and only until login. Tried locking file but did no good. But at least I now know it can be done with HDMI, so that is a nice progress. :D

Any other suggestions?

I do notice that even if I delete the whole com.apple.windowserver.displays.plist file, all my previous settings are restored once rebooted. All my saved connections re-appear even though the file is deleted... Guess they reside somewhere else too?

@GetVladimir
Copy link
Author

@Amritus are you also locking the users display file located in ByHosts:
/Users/[yourname]/Library/Preferences/ByHost/com.apple.windowserver.displays.[UDID].plist

@Amritus
Copy link

Amritus commented Jun 26, 2024

@GetVladimir Yeah!!!

WooHoo! Now it works, even after reboot and login.

But, I disconnect and re-connect A LOT of screens, though for this specific purpose I think the UUID will stay the same as the HDMI will be connected to the same port on the same product.

However, if things go off again, I guess I just have to make a chron job or similar to check status of added UUID and then run a script that fixes it.

So boring that Apple just won't address this.

@GetVladimir
Copy link
Author

@Amritus Awesome! Glad to hear that you got it working.

Yes indeed, it would be very convenient if they just added a menu option in the display settings to choose between RGB and YCbCr color output, similar like they already have on tvOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment