Skip to content

Instantly share code, notes, and snippets.

@GetVladimir
Last active November 15, 2024 14:00
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.

@traderdude123
Copy link

traderdude123 commented Jul 9, 2023

@jacek-jablonski
@esmorun

I have not tested on Sonoma. waiting for public release.

But i have read reports from other users who are using beta. They are even getting 4k 120hz RGB 10 bit with AMD 6000 Series cards on hackintosh's as well. This was not possible on Ventura. So its high likely that the sleep issue could be fixed on Sonoma.

if anyone is brave enough to test it on beta. It would be great. If anyone does test it. please let us know.

@GetVladimir
Copy link
Author

I've just tested it on Sonoma Developer Beta 3. I've deleted all the display plist preferences files and started fresh.

Here are the results:

  • The HDMI to HDMI connection still defaults to YCbCr Color Output (as usual)
  • The USB-C to DisplayPort connection defaults to RGB Color Output (as usual)
  • 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 (so this one seems to be fixed, at least on a M1 Mac mini)
  • There was a strange issue with the Magic Mouse connecting and disconnecting every few seconds after restarting Sonoma a few times. Turning off the Magic Mouse and turning it on seems to fix this for the moment.

@traderdude123
Copy link

traderdude123 commented Jul 9, 2023

@GetVladimir

Thanks for the confirmations. Finally, some progress.

Also the HDMI-HDMI defaulting to YCBCR is actually correct since HDMI is predominantly used by TVs and YCBCR gives the best picture quality. However if you want to use it as a Monitor we need RGB. But normally its not expected that people use TV as monitors.

For monitors , USB-C/DP is primary connection and hence defaults to RGB , which is also the correct thing to do.

But what apple needs to provide is a user selectable option in the Display section of settings for YCBCR or RGB.

@GetVladimir
Copy link
Author

@traderdude123 not a problem, thanks for the reply.

Yes, indeed. It seems that Sonoma is getting more optimized than Ventura ever was

@DeepSubMicronMusic
Copy link

Hi @GetVladimir , many thanks for this info, I have just fixed a new M2 mac mini connected to an Acer widescreen monitor via HDMI (for the moment, usb->DP is the next step) using it.

However I am wondering why your examples have the Range key set to 1, which appears to give limited range colour; surely for any computer monitor, and to be honest any modern TV really, you want full range colour, which appears (visually at least, the monitor doesn't report the full format details in its OSD unfortunately) to be the case when the range key is set to 0.

@GetVladimir
Copy link
Author

@DeepSubMicronMusic Thank you for the reply and I'm glad that you got RGB color output working.

That's a good question. I don't really have confirmation that the Range key affects full and limited color (even though initially that might make sense).

The reason why I set the Range to 1 in the original tutorial is because macOS ignored the display plist file if you set it to 0.

If you can set it to 0 and macOS still accepts the plist file in the newer versions, you might want to try using that instead

@DeepSubMicronMusic
Copy link

@GetVladimir OK, so although it is a data point of one, I can say that on the latest OS release changing this value to zero for me has the effect that I would expect switching to full range, i.e. blacks are now properly black, and whites are properly white. I wish I still had access to a HDMI analyser to see what was really happening both with the signal format and the infoframes, but sadly that was a former life.

I would suggest giving it another go, for me it made a big difference to the contrast on the UI in dark mode, but more importantly shadow detail on images now looks correct rather than washed out and posterized (which is the problem that actually led me to find this post, because I recognised that it probably meant the output the format was wrong).

@GetVladimir
Copy link
Author

@DeepSubMicronMusic thank you for the info, I appreciate it. Those are good points.

I think we might need to test it connected to a TV, since those usually have options in the settings to show when they are receiving limited or full range.

Technically, they should adjust automatically on the receiving and to match the output source, but it's nicer to have full range when possible

@cooltig
Copy link

cooltig commented Jul 13, 2023

Hi Vladimir,

thank you for all your work and detailed instructions but I tried that from your Youtube video but it doesn't work. I still get fuzzy colors wenn switching my Dell monitor to RGB mode.
I have a MacBook Pro 14 (M1 Pro) and MacOS 13.4.1 (c).
Any ideas?

@GetVladimir
Copy link
Author

@cooltig thank you so much for the comment and for the details.

I'm guessing this might be the same question posted on the Reddit topic, so I'm going to post the answer here too for future reference.

If your monitor is Dell and uses USB-C to USB-C connection, please make sure to turn off High Data Speed and choose High Resolution instead in the Monitor menu.

As you've mentioned, you might also need to turn off MST and DDC/CI

@dainiusm07
Copy link

@GetVladimir Thank you very very much!

@GetVladimir
Copy link
Author

@dainiusm07 you're very welcome.

Thank you so much for your comment and I’m glad if you found the guide useful

@DeepSubMicronMusic
Copy link

@GetVladimir A quick update from my playing about. While setting up more things on the new mac I did something (possibly related to using the rectangle window manager or tinkertool to change some dock settings) which caused the display output format to reset again for my login, i.e. it was still fine for the login screen on reboot but as soon as I logged in I was back to the wrong output format.

Having backed out the changes I had been making to the dock settings and uninstalling bits of software running at login that might have been effecting it to no avail and finding that it wasn't something simple like a new display plist file appearing in my local library, I was a bit concerned that I wasn't going to be able to get the output format back to what I wanted. So I had a step back and a bit of a think about what was going on.

I came to the conclusion that the advice to delete the user specific display plist in ByHost was probably mistaken and that the better advice would be to make the same plist property changes to both the system file and the local user version of the file. As I had saved the original before deleting it (I hope everyone has taken that advice) I put it back with the change made and it is now working again. As a side note, this doesn't solve the problem of the screen sleeping breaking it again until reboot, but I think it is a more robust change than simply deleting the user version of the file.

@GetVladimir
Copy link
Author

@DeepSubMicronMusic thank you for the update and for the details.

Yes, the alternative method modifies the ByHost display plist file, same as you've suggested: https://gist.github.com/GetVladimir/c89a26df1806001543bef4c8d90cc2f8#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

Losing the RGB color output when waking from sleep was a bug in macOS, and it seems to be fixed in macOS Sonoma Beta

@dainiusm07
Copy link

It seems that when RGB output is lost after waking up from sleep it could be restored without restarting the Mac. Manual Log Out is enough to get back the RGB

@GetVladimir
Copy link
Author

@dainiusm07 yes, you're right. As long as the ByHost display plist file is modified, it should be re-read on login again.

It should technically be read on wake from sleep, but there seems to be a bug in the later versions of Ventura.

In macOS Sonoma beta, the waking up from sleep seems to be fixed already

@dainiusm07
Copy link

I managed to resolve RGB loss on wake up bug by accident on my macbook. For folks using macbooks:

  1. Unplug your monitor
  2. Restart macos
  3. Login
  4. Plug your monitor
  5. Put macbook to sleep manually & verify that after waking it up RGB is in place

I'm on Macbook Pro M1 with Ventura 13.4.1 (c), plugged via HDMI-HDMI. Also I have edited both plist files in /Library/Preferences and in $HOME/Library/Preferences/ByHost and both files are configured to support RGB on both variants (macbook screen + external monitor & only external monitor)

@GetVladimir
Copy link
Author

@dainiusm07 thank you for the details and for the step-by-step guide for the solution.

Let's see if other users can replicate it too.

I'm currently on the Sonoma beta, and it seems to work by default

@zdenek-jonas
Copy link

zdenek-jonas commented Jul 17, 2023

I can confirm that the procedure from @dainiusm07 worked on my M2 14 mackbook pro too.

@GetVladimir
Copy link
Author

@zdenek-jonas thank you so much for checking this and for the confirmation

@zdenek-jonas
Copy link

zdenek-jonas commented Jul 18, 2023

Unfortunately, the next day to wake up the PC it's flipped again. I am going to try Sonoma Beta

@dainiusm07
Copy link

@zdenek-jonas Have you edited both files in /Library/Preferences and $HOME/Library/Preferences/ByHost ? Make sure that your external monitor refresh rate is set to the same value on all variants of monitors combinations & it is the same in both files. Different refresh rates causes external monitor to flash on closing/opening macbook screen and I guess it could cause some kind of issues

@zdenek-jonas
Copy link

@zdenek-jonas Have you edited both files in /Library/Preferences and $HOME/Library/Preferences/ByHost ? Make sure that your external monitor refresh rate is set to the same value on all variants of monitors combinations & it is the same in both files. Different refresh rates causes external monitor to flash on closing/opening macbook screen and I guess it could cause some kind of issues

I have already installed Sonoma Beta. Now it stands RGB. Before that everything worked fine until I closed the laptop once, connected to the monitor. Since then, I've tried absolutely everything but it never worked like it used to. Let's see now.

@dangh
Copy link

dangh commented Jul 19, 2023

If anyone willing to pay for an easier solution, buy BetterDisplay app and follow this instruction. There're some great improvement over the plist manipulation method:

  • The EDID get re-applied when you turn the monitor on/off automatically, so you don't have to restart your Mac.
  • If some other apps mess up your display (Dota 2 in my case), it won't anymore because the display now has a fixed config. Even if it does, you can just re-apply the EDID manually.

@BermudaBen
Copy link

BermudaBen commented Jul 30, 2023

This method doesn't work on my M1 MacBook (Monterey). The lines of code to be changed didn't exist in my displays plist file, so I just added them. What I found confusing was that my plist file seemed to contain much more code than Vladimirs. It contains around 650 lines of code with a repeating structure of "Current Info", "Rotation" and "UnmirrorInfo". I inserted the additional code just below the first "Current Info" block, exactly as in Vladimirs screenshot.

I have a Dell U2720Q monitor connected via USB-C. It seems that whenever I first launch the MacBook and then switch on the monitor, the color is set to YPbPr. If I want RGB color I need to reset the monitor to RGB (which results in a pink-green display), then unplug the USB-C cable and plug it in again. Modifying the displays plist file hasn't changed this behavior. I also tried deleting both plist files (including the on in the ByHost folder) and then modifying the one that has been newly created.

@GetVladimir
Copy link
Author

@BermudaBen thank you for your comment.

Please check in your monitor setting for an option where you can choose between "High Data Speed" and "High Resolution" and set it to "High Resolution".

If that doesn't work or if you need the faster data on the USB ports of the monitor, please connect the M1 MacBook to the Dell U2720Q with USB-C to DisplayPort cable instead

@BermudaBen
Copy link

@GetVladimir Thank you for your reply. The monitor is set to "High Resolution". As for the connection: This would mean I won't be able to charge the MacBook from the Dell monitor, right? Why would it make a difference to use the monitors DP port instead of the UBS-C port? The video signal is DP in both cases. And: Do you know if this is a Dell-specific issue?

@GetVladimir
Copy link
Author

@BermudaBen not a problem, thank you for the reply.

When you mentioned that you have over 650 lines of repeating instances of Current Info in the plist file, this usually points to having a dock in the middle of the connection.

It seems that the USB-C to USB-C connection is considered as connected through a dock inside the monitor and then being converted.

The M1 MacBook doesn't seem to see it same as having an actual USB-C to DisplayPort connection.

This might depend on what type of conversion happens in the monitor and it's not isolated to only Dell monitors.

@satori-mitora
Copy link

After numerous attempts without success, I finally managed to succeed. I will record what I tried.

[1] I attempted to edit /Library/Preferences/com.apple.windowserver.displays.plist. This method involved changing the refresh rate and other display settings, but it failed.

[2] Next, I tried alternative method, but I couldn't find com.apple.windowserver.displays.[UUID].plist in /Users/username/Library/Preferences/ByHost. However, rotating the screen created a new com.apple.windowserver.displays.[UUID].plist. After executing Terminal commands, I finally achieved RGB!

Thanks to GetVladimir and everyone.

Lastly, I'll provide details about my setup: Mac mini M2, Mac OS 13.4.1 (c), HDMI to HDMI, DELL S2722DC.

@GetVladimir
Copy link
Author

@satori-mitora thank so much for your comment and for the detailed steps. Glad to hear that you got RGB color output working

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