Skip to content

Instantly share code, notes, and snippets.

@GetVladimir
Last active December 31, 2024 10:19
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

@syifan Yes, that is indeed a bug since macOS Ventura. It hasn't been fixed with 13.1 either.

What would be best is if the monitor support works out of the box in macOS, so that we don't need to jump through hoops and modify plist files just to make RGB color output working

@op0815
Copy link

op0815 commented Dec 27, 2022

Hi,
I am using a MacBook Pro M1 with an (old) 27" Monitor (Acer K272HUL), macOS Ventura 13.0.1.
I have tried to add the above section (LinkDescription …) to my com.apple.windowserver.displays.plist to force the output to RGB.
But: After restart the lines just disappear and the output i still flat.
Is there a solution?

@GetVladimir
Copy link
Author

@op0815 thank you for your question and the details.

Yes, there are a few things you can try:

  • Please make sure to use a plain text editor to make the changes. If you don't have have one, you can use the free, open source CotEditor, that's available on the Mac App Store: https://apps.apple.com/us/app/coteditor/id1024640650?mt=12
  • Try to edit both the plist file in:
    /Library/Preferences/com.apple.windowserver.displays.plist
    and in
    /Users/yourname/Library/Preferences/ByHost/com.apple.windowserver.displays.[UDID].plist
  • Use a direct USB-C to DisplayPort or USB-C to HDMI cable from the MacBook to the monitor. Avoid using a dock, hub or adapters
  • Update to macOS 13.1, just to be on the latest version

Let us know how it goes or if you have any additional questions.

Wish you a Merry Christmas and Happy New Year holidays!

@op0815
Copy link

op0815 commented Dec 27, 2022

@GetVladimir thank for your tips.

But: Did not work …

  • I am using BBedit
  • I have edited both files, after the restart (after the update) only the file in the ByHost-folder contained the "LinkDescription"-section, the one in the /Library/Preferences/ this section "disappeared" again
  • the monitor is connected by a HDMI cable, I have tried USB-C to HDMI (unfortunately: with Adapter): the monitor "says": No Signal
  • I have updated to macOS 13.1

Merry Christmas and Happy New Year to you too!

@GetVladimir
Copy link
Author

@op0815 Thank you :) Also, thanks for the update and the details.

Something seems to be overwriting the plist file on boot. Do you have any apps installed that might be changing the resolution or something similar?

@op0815
Copy link

op0815 commented Dec 28, 2022

@GetVladimir I hope: No. (I had installed SwitchResX: I uninstalled this app some days ago)

Now: After today's restart the /Library/Preferences/ contained the "LinkDescription"-section and the result seems OK
Although: the modification date of the file com.apple.windowserver.displays.plist was set to boot-time …

@GetVladimir
Copy link
Author

@op0815 Awesome! Thanks for the update and I'm glad to hear that you got RGB color output working

@simprince
Copy link

simprince commented Jan 4, 2023

It doesn't work for me on Ventura 13.1. After I put the modified file back to the Preferences/ folder and re-plug my monitor, the system overrides the file (I can tell from the new timestamp of the file). Then if I open the new file, the LinkedDescription section is completely gone.

Context: I am connecting my MBP 16" to two identical Dell U3014 monitors. One of them works and the other one doesn't. If I switch ports, the monitor that works doesn't work.

UPDATE: I change the broken monitor's cable from HDMI-HDMI to DP-USBC so that I connect both monitors to MBP with DP-USBC and it works without any overrides.

@GetVladimir
Copy link
Author

@simprince thank you for your comment and for the updated solution! I'm glad to hear that you got RGB color output working on both monitors

@fecabianchi
Copy link

@GetVladimir you can get RGB with USBC-HDMI cable or is fixed only with USBC-DP?

@GetVladimir
Copy link
Author

@fecabianchi only the USB-C to DisplayPort cable seems to work without the need to modify the plist files

@yackinn
Copy link

yackinn commented Jan 12, 2023

Using usb-c to hdmi (Samsung TV) and mDP to DisplayPort (4k Dell Monitor via dock) outputs non-rgb mode on the TV.
When the Dell Monitor is unplugged the TV outputs rgb correctly.

When I change the plist file and restart it works fine until the Dell Monitor is turned on. The plist file changes will revert and the rghb mode on the TV won't work.

Does anyone has a similar issue and a potential solution?

@GetVladimir
Copy link
Author

@yackinn thank you for the comment and the details.

There seems to be an issue with macOS 13.1 that overwrites the plist files when waking up from sleep or connecting/turning on a monitor after the Mac powers on.

The workaround is to get a USB-C to DisplayPort cable (without using a dock) for the monitor.

The other alternative at the moment is to keep a backup of the working display plist files and restore them as needed.

@yackinn
Copy link

yackinn commented Jan 12, 2023

Thanks for your response.

That's the current setup:
Monitor 1: Samsung 4k TV (only HDMI available)
Monitor 2: Dell UP2715KT (only mDP available when used in 4k mode)

What would you suggest how to connect both monitors?
USB-C wouldn't be possible as there's no matching port on the monitors.

@GetVladimir
Copy link
Author

GetVladimir commented Jan 12, 2023

@yackinn Thanks for the reply.

Are you using a Mac mini or MacBook?

If you're using a Mac mini, you can use an HDMI-to-HDMI cable for the Samsung TV and USB-C-to-miniDisplayPort for the Dell Monitor.

You might still need to modify the plist files.

If you already have an USB-C-to-HDMI cable, you can use that for the Samsung TV instead of the HDMI-to-HDMI.

This will occupy both USB-C ports on the Mac mini though.

@yackinn
Copy link

yackinn commented Jan 12, 2023

I tried to do that.

Using usb-c to hdmi (directly connected from Macbook to Samsung TV) also doesn't work if the Dell Monitor is connected as well.
I'm not sure why the rgb mode only works if the Dell Monitor is not connected.

Do you have an idea if it might get fixed so the plist file won't get overridden on startup?

@GetVladimir
Copy link
Author

@yackinn If you're using an M1 MacBook, I think it only can support 1 external display with full 4K60 RGB resolution.

Connecting more than 1 external display will limit the bandwidth or just not work properly.

Source: https://support.apple.com/en-ie/HT202351

@yackinn
Copy link

yackinn commented Jan 12, 2023

That's odd. It used to work before I updated to Ventura though.

@GetVladimir
Copy link
Author

@yackinn there does seem to be some issues with macOS 13.1.

If you had it working before, there is a chance it might work in a future update.

Their official specification is that it only allows for 1 external displays. The dock that you use however perhaps provides its own display output

@cyan-gorilla
Copy link

cyan-gorilla commented Jan 17, 2023

Hi,
I'm on a MacStudio which I had updated recently, thus losing the modifications I had initially done last year. The way I got it to stick was by setting both files to Read Only and Locking them.

So far, so good. Thank you so much for this fix!

@GetVladimir
Copy link
Author

@cyan-gorilla thank you so much for your comment and for the solution for locking the plist file!

I'm glad to hear that you got RGB color output working properly

@ahuse
Copy link

ahuse commented Jan 19, 2023

The way I got it to stick was by setting both files to Read Only and Locking them.

This is not working for me on my MacBook Air M1. Unplugging and Re-plugging the monitor still resets the file, despite of setting all permissions to read-only.

@cyan-gorilla
Copy link

permissions to read-only.

Did you also lock it?
I don't really disconnect my main display all that often, but I do with the second one and the file hasn't changed yet (my second display is an iPad Pro).

@ahuse
Copy link

ahuse commented Jan 22, 2023

Did you also lock it? I don't really disconnect my main display all that often, but I do with the second one and the file hasn't changed yet (my second display is an iPad Pro).

Thanks. I was not aware of locking files in MacOS. Indeed the file is not changed/overwritten anymore. But the monitors is only in RGB-Mode after restarting the macbook. If i disconnect or open and close the lid it goes right back to YPBPR until restart.

For everyone having this problem. Please file a bug report with apple. The more the better.

@sobotka
Copy link

sobotka commented Jan 23, 2023

I am 80% sure that HDR mode is performing a double up encoding leading to incorrect output with HDR mode on.

It seems like the signal that is output has encoded primaries inset and the result is a lack of chroma, due to this potential double up. Setting the characterization to “Generic RGB” seems to get the results closer, but is still wrong.

Curious if anyone else has explored this error? One potential solution would be to create a device link characterization for HDR, if it can be determined where the double up encoding is happening.

@GetVladimir
Copy link
Author

@sobotka thank you for your comment and for the info.

That is an interesting finding. I don't know of a proper way to check and confirm this on my setup.

Perhaps if other users had more experience with HDR issues can confirm this or mention if there is any workaround.

@austintackaberry
Copy link

I'm on a brand new Macbook Air M2 Ventura 13.0 connecting to Dell UltraSharp 27 Monitor via USB-C. The setup was working for me for about a day without any issues or overrides.

Randomly, I started to experience this issue, and I tried the steps here (thanks for sharing) but they did not work. LinkDescription did not exist for me so I added it and also /Users/yourname/Library/Preferences/ByHost/com.apple.windowserver.displays.[UDID].plist file does not exist for the UDID of my external monitor (I see the Mac screen, but not the external monitor).

When I reboot, and check the file, my changes to /Library/Preferences/com.apple.windowserver.displays.plist are gone. Anyone else encounter this?

@GetVladimir
Copy link
Author

GetVladimir commented Jan 26, 2023

@austintackaberry Thank you for your comment.

There are indeed a lot of issues with Ventura 13.0. If possible, try updating to Ventura 13.2 and this might solve your issue without the need to edit the plist files.

If you must stay on 13.0, you can try making a backup of both plist files, delete them and then reboot so that macOS can regenerate then from beginning.

@austintackaberry
Copy link

@GetVladimir Thanks for your reply! I have upgraded to Ventura 13.2 and unfortunately have the same problems.

Monitor is still YPbPr and LinkDescription does not exist for me in /Library/Preferences/com.apple.windowserver.displays.plist so I added it. And /Users/yourname/Library/Preferences/ByHost/ does not have any files for the UDID of my external monitor (I see files for the Mac screen, but not the external monitor).

I have also tried to delete /Library/Preferences/com.apple.windowserver.displays.plist and reboot, but still not working for me

@GetVladimir
Copy link
Author

@austintackaberry thanks for the update.

Check in the plist file if there are multiple UUIDs where you need to add the Link Description key. It might need to be added more than once.

Also, do you use a direct USB-C to USB-C cable to connect to your monitor, without any adapters or docks in between?

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