Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A script to fix EDID problems on external monitors in Mac OS. Source: http://embdev.net/topic/284710

patch-edid.rb

A script to fix EDID problems on external monitors in Mac OS.

  1. Connect the problem monitor.

  2. Download this script into your /System/Library/Displays/Overrides (note: this file is only writeable by root, so some commands require sudo).

cd /System/Library/Displays/Overrides
sudo curl -O https://gist.github.com/ejdyksen/8302862/raw/patch-edid.rb
  1. Run the script we just downloaded (as root again). This creates a new display override plist.
sudo ruby patch-edid.rb
  1. Disconnect and reconnect the monitor.

Source: http://embdev.net/topic/284710

#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
#
# Update 2013-06-24: added -w0 option to prevent truncated lines
require 'base64'
data=`ioreg -l -w0 -d0 -r -c AppleDisplay`
edid_hex=data.match(/IODisplayEDID.*?<([a-z0-9]+)>/i)[1]
vendorid=data.match(/DisplayVendorID.*?([0-9]+)/i)[1].to_i
productid=data.match(/DisplayProductID.*?([0-9]+)/i)[1].to_i
puts "found display: vendorid #{vendorid}, productid #{productid}, EDID:\n#{edid_hex}"
bytes=edid_hex.scan(/../).map{|x|Integer("0x#{x}")}.flatten
puts "Setting color support to RGB 4:4:4 only"
bytes[24] &= ~(0b11000)
puts "Number of extension blocks: #{bytes[126]}"
puts "removing extension block"
bytes = bytes[0..127]
bytes[126] = 0
bytes[127] = (0x100-(bytes[0..126].reduce(:+) % 256)) % 256
puts
puts "Recalculated checksum: 0x%x" % bytes[127]
puts "new EDID:\n#{bytes.map{|b|"%02X"%b}.join}"
Dir.mkdir("DisplayVendorID-%x" % vendorid) rescue nil
f = File.open("DisplayVendorID-%x/DisplayProductID-%x" % [vendorid, productid], 'w')
f.write '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">'
f.write "
<dict>
<key>DisplayProductName</key>
<string>Display with forced RGB mode (EDID override)</string>
<key>IODisplayEDID</key>
<data>#{Base64.encode64(bytes.pack('C*'))}</data>
<key>DisplayVendorID</key>
<integer>#{vendorid}</integer>
<key>DisplayProductID</key>
<integer>#{productid}</integer>
</dict>
</plist>"
f.close
@chiehchu

This comment has been minimized.

Copy link

commented Aug 12, 2015

how about roll back?

@PrfsrX

This comment has been minimized.

Copy link

commented Aug 25, 2015

Anybody?... Would also love a roll back :)

@unknownzerx

This comment has been minimized.

Copy link

commented Sep 13, 2015

Will it work on El Capitan? With rootless...

@0x62ash

This comment has been minimized.

Copy link

commented Oct 1, 2015

On El Capitan (disabled rootless) after patching I got acid colors.
So Im using apple default profiles for my Asus VX239 with terrible font smoothing :(

@mirfilip

This comment has been minimized.

Copy link

commented Oct 22, 2015

No it won't work with El Capitan. /System/Library/Displays/Overrides doesn't exist and cannot be created or modified even by sudo.

I wonder if turning off SIP and adding this path to excluded paths in /System/Library/Sandbox/rootless.conf. Anyone tried that?

EDIT: Just turned off rootless, patch obviously still works as expected. Also, it's worth to new overrides path to excluded paths in rootless cfg.

@aocana

This comment has been minimized.

Copy link

commented Nov 6, 2015

not works for my asus vx239
:-(

@serefacet

This comment has been minimized.

Copy link

commented Nov 10, 2015

Not works for my asus vx239 too . I nearly try all kinds of these solutions , DELL and Samsung Monitors seems ok , but I have no solution on asus vx239. Any help is appreciated.

@nooks

This comment has been minimized.

Copy link

commented Nov 14, 2015

Not work in Mac mini 2009 with VGA display

+-o AppleDisplay  <class AppleDisplay, id 0x1000048fa, registered, matched, active, busy 0 (0 ms), retain 8>
    {
      "IOClass" = "AppleDisplay"
      "CFBundleIdentifier" = "com.apple.iokit.IOGraphicsFamily"
      "IOProviderClass" = "IODisplayConnect"
      "DisplayProductID" = 1815
      "IOPowerManagement" = {"CapabilityFlags"=49152,"MaxPowerState"=3,"CurrentPowerState"=3}
      "IODisplayPrefsKey" = "IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/IGPU@2/AppleIntelFramebuffer@1/display0/AppleDisplay-756e6b6e-717"
      "IODisplayParameters" = {"bgsc"={"min"=0,"max"=65536,"value"=65536},"pscn"={"min"=8800,"max"=10000,"value"=10000},"rgsc"={"min"=0,"max"=65536,"value"=65536},"cmod"={"min"=0,"max"=4096,"value"=1},"ggsc"={"min"=0,"max"=65536,"value"=65536},"cyuv"={"min"=0,"max"=268435456,"value"=268435456},"vblm"={"min"=0,"max"=196608,"value"=65536},"gsc "={"min"=0,"max"=65536,"value"=65536},"colr"={"min"=0,"max"=18446744073709551615,"value"=257}}
      "IOProbeScore" = 2000
      "IOMatchCategory" = "IODefaultMatchCategory"
      "IODisplayConnectFlags" = <00000000>
      "DisplayVendorID" = 1970170734
      "DisplaySerialNumber" = 0
    }
@maurei

This comment has been minimized.

Copy link

commented Nov 24, 2015

Maybe you want to update this topic with the following relevant information:

  1. In El Capitan
    /System/Library/Displays/Overrides
    is now located at
    /System/Library/Displays/Contents/Resources/Overrides
  2. Even with sudo, any write operations will not be permitted. To fix this, reboot in recovery mode (cmd+r during reboot), under utils, open up the terminal. Do csrutil disable. Reboot, and run the script in the relocated folder.
@martystack

This comment has been minimized.

Copy link

commented Dec 2, 2015

Thanks Maurei for the update.

And if ANYONE is interested in why it doesn't work in OSX El Captain, it is because...

OS X 10.11 « El Capitan » introduces a feature called « System Integrity Protection », aka « SIP » or « rootless » . A lot has been said about this feature on several information media.

Because of this SwitchResX isn't working without overriding the SIP- Maurei explained the work around.

You can read more on this issue here:
http://www.madrau.com/support/support/srx_1011.html

@oliviergilloire

This comment has been minimized.

Copy link

commented Feb 10, 2016

Hi

OS X El Capitan, did all of the above (csrutil disable, root enabled) but the ruby patch-edid.rb just doesn't output anything (no error message, no output on terminal...)

macpro:Overrides root# ruby patch-edid.rb
macpro:Overrides root#
No command line output whatsoever?

The command "ioreg -l -w0 -d0 -r -c AppleDisplay" properly works though and outputs the below:

+-o AppleDisplay <class AppleDisplay, id 0x100000c3e, registered, matched, active, busy 0 (0 ms), retain 8>
{
"IOClass" = "AppleDisplay"
"CFBundleIdentifier" = "com.apple.iokit.IOGraphicsFamily"
"IOProviderClass" = "IODisplayConnect"
"DisplayProductID" = 16540
"IODisplayEDID" = <00ffffffffffff0090ac9c404c37303231170104b5351e783a1df5ae4f35b3250d5054000000010101010101010101010101010101014dd000a0f0703e80302035000f282100001a000000ff0030303030303030303030303030000000fc0044454c4c20555032343134510a000000fd001d4b1f8c36000a20202020202000cc>
"IODisplayPrefsKey" = "IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/GFXB@3/IOPP/GFX2@0/ATY,KaniS@5/AMDFramebufferSI/display0/AppleDisplay-90ac-409c"
"IOPowerManagement" = {"CapabilityFlags"=49152,"MaxPowerState"=3,"CurrentPowerState"=3}
"IOProbeScore" = 2000
"IODisplayParameters" = {"bgsc"={"min"=0,"max"=65536,"value"=65536},"pscn"={"min"=10000,"max"=10000,"value"=10000},"rgsc"={"min"=0,"max"=65536,"value"=65536},"thrm"={"min"=0,"max"=120,"value"=51},"cmod"={"min"=0,"max"=4096,"value"=1},"ggsc"={"min"=0,"max"=65536,"value"=65536},"cyuv"={"min"=0,"max"=268435456,"value"=268435456},"dith"={"min"=0,"max"=1,"value"=0},"vblm"={"min"=0,"max"=196608,"value"=65536},"gsc "={"min"=0,"max"=65536,"value"=65536},"colr"={"min"=0,"max"=268439825,"value"=268439553}}
"IOMatchCategory" = "IODefaultMatchCategory"
"AppleDisplayType" = 2
"IODisplayAttributes" = {"IODisplayAttributes"=<676174760000000073676c6600000000726c6f630100000063706220040000006364670080808000676c666400000000>}
"AppleSense" = 37119
"IODisplayConnectFlags" =
"DisplayVendorID" = 37036
"DisplaySerialNumber" = 842020684
}

What could be wrong here?

@donald-jackson

This comment has been minimized.

Copy link

commented Mar 1, 2016

May I ask potentially a different question? I have an external GPU with HDMI 2.0 which works running YCBR 4:4:4 when in Bootcamp but I can't seem to force it to do so in OS X. How can I modify this script to force the only mode available to YCBR 4:4:4 (rather than RGB) as this is in fact a TV. Attached is what I currently get (no custom resolutions, only the HDMI pixel clock patch).
screenshot 2016-03-01 09 28 34

@ojczeo

This comment has been minimized.

Copy link

commented Apr 9, 2016

Awesome, thanks for sharing!

@cheynewallace

This comment has been minimized.

Copy link

commented May 23, 2016

Twice now, this script has saved me from basically having to throw away a monitor. After a recent upgrade to El Capitan I thought It was all over, thanks also to @maurei for the info regarding the new file location. Never would of found that

@davidbdeath

This comment has been minimized.

Copy link

commented Aug 26, 2016

Is there a way to use this to force 10Bit? My display supports it but even after running the patch my Mac doesn't.

@AlexCoderBit

This comment has been minimized.

Copy link

commented Aug 29, 2016

Made my day for second time now ))
Though it took a while for me to make it work on a same MBP 13 but with a new monitor.

@ImRob

This comment has been minimized.

Copy link

commented Sep 12, 2016

Not working for me, i'm about to return this monitor. Thanks anyway @maurei

@ghost

This comment has been minimized.

Copy link

commented Sep 21, 2016

Hi guys, I had this working on El Capitan, but I've updated to Sierra and performed all the process (turned off SIP too). I can download the file into the correct directory, but for some reason it isn't running the script. What could be going wrong?

@aocana

This comment has been minimized.

Copy link

commented Oct 1, 2016

Hi,

I have ASUS VX239 and OS sierra. I have connected this monitor to my macbook pro and doesn't work, someone can help me to run this monitor with my macbook pro.?

thanks!!

@Zweedeend

This comment has been minimized.

Copy link

commented Oct 13, 2016

I have to go through this process every time there is a new update for the Mac. Here are the steps I took for Sierra (they are the same for El Capitan)

  1. Reboot into Recovery Mode, by holding ⌘ + R when the computer is booting
  2. Open the Terminal window by going to Utilities -> Terminal
  3. Type csrutil disable; reboot and press Enter
  4. Let the computer boot normally (not Recovery Mode)
  5. Follow the original instructions (on the top of this page), except that the folder in step 2 is changed. It is now /System/Library/Displays/Contents/Resources/Overrides
  6. Don't stop here. It is important on re-enable the System Integrety Protection. Reboot into Recovery Mode, by holding ⌘ + R when the computer is booting
  7. Open the Terminal window by going to Utilities -> Terminal
  8. Type csrutil enable; reboot and press Enter
  9. Let the computer boot normally. Done
@antwake

This comment has been minimized.

Copy link

commented Oct 28, 2016

for those who have no output when running the script (like @oliviergilloire ) be sure that the file (patch-edid.rb) isn't empty.
I had to download it manually and copy/paste it in /System/Library/Displays/Contents/Resources/Overrides
Worked with my 21:9 AOC Q2963PM

@mickeyklein

This comment has been minimized.

Copy link

commented Dec 20, 2016

When I type in the script it asks for a password? anyone know what to do with that? I don't have a password on my mac

@joserocha3

This comment has been minimized.

Copy link

commented Dec 24, 2016

@mickeyklein the password is your user account password, the one you type in when you turn on your mac

@MacMiniUser2017

This comment has been minimized.

Copy link

commented Jan 19, 2017

I have a Mac mini (2011) with Sierra conected on a Philips TV. Because a get sometimes strange colors I try the solution on this webpage. But I think that I do something wrong because I get a error… I hope you can help me.

This is the error I get in the terminal:

patch-edid.rb:11:in match': invalid byte sequence in UTF-8 (ArgumentError) from patch-edid.rb:11:inmatch'
from patch-edid.rb:11:in `

'
I did the steps below. Only I remove the line "sudo curl -O https://gist.github.com/ejdyksen/8302862/raw/patch-edid.rb" because the script wash empty. So I replace it with the script in the download file.

1 Reboot into Recovery Mode, by holding ⌘ + R when the computer is booting
2 Open the Terminal window by going to Utilities -> Terminal
3 Type csrutil disable; reboot and press Enter
4 Let the computer boot normally (not Recovery Mode)
5 I open the terminal and type this:

cd /System/Library/Displays/Contents/Resources/Overrides

(I place patch-edid.rb in the map Overrides)

sudo ruby patch-edid.rb

6 Don't stop here. It is important on re-enable the System Integrety Protection. Reboot into Recovery Mode, by holding ⌘ + R when the computer is booting
7 Open the Terminal window by going to Utilities -> Terminal
8 Type csrutil enable; reboot and press Enter
9 Let the computer boot normally. Done

@juanignaciosl

This comment has been minimized.

Copy link

commented Jan 20, 2017

@MacMiniUser2017 thank you very much, you saved me!

@juanignaciosl

This comment has been minimized.

Copy link

commented Jan 28, 2017

FYI I just upgraded to Beta 4 and the external display stopped working, only a blue screen was disabled. I'm not sure whether it's related with the override or it was caused by a wrong installation. I'll do a full wipe (in a few days) and try again.

@cumanzor

This comment has been minimized.

Copy link

commented Mar 29, 2017

Confirming this works on 10.12.4. Just make sure you are using the correct paths (/System/Library/Displays/Contents/Resources/Overrides) and that csrutil is disabled (and then renable it back)

@niewb

This comment has been minimized.

Copy link

commented May 3, 2017

@ejdyksen how do I undo the patch/revert to how I had things before?

@natefinch

This comment has been minimized.

Copy link

commented May 26, 2017

This fixed my problem (late 2016 Macbook Pro driving a Dell U3014 via Thunderbolt to HDMI). I expected my display to stop being listed as "NTSC" under the refresh rate, but it did not. I almost thought maybe it hadn't worked, except then I noticed the fonts looked a lot better, so I guess it's fine. Wanted to note that for anyone coming here.

@gevariya-ajit

This comment has been minimized.

Copy link

commented Jun 18, 2017

Is this new title showing anywhere? I am not getting affected with this changes for new display LG 24MP88HV-S.

Display with forced RGB mode (EDID override)

@faywong

This comment has been minimized.

Copy link

commented Sep 6, 2017

It doesn't work on Sierra.

faywongdeMBP-2:~ faywong$ sudo ruby ./patch-edid.rb
Password:
./patch-edid.rb:1: unknown regexp option - b
@niewb

This comment has been minimized.

Copy link

commented Sep 12, 2017

How do I undo the patch? I think it made things worse. @ejdyksen

@GonzaloGM

This comment has been minimized.

Copy link

commented Jan 6, 2018

Late, but might help: to revert it, disconnect your external display, then delete the folder from the Overrides folder (you'll need to disable SIP) and reconnect the display (I restarted after deleting it but not sure it's necessary).

@bennburke

This comment has been minimized.

Copy link

commented Mar 31, 2018

Hello all, I'm running 10.13.2 on my mid 2011 MBA (13") and desperately trying to run a Fujitsu P24W-7 monitor.
I followed all the steps and all I get at the end of these steps is this:

patch-edid.rb:11:in <main>': undefined method []' for nil:NilClass (NoMethodError)

any ideas on what I could be doing wrong here?
many thanks!

@Bootquick

This comment has been minimized.

Copy link

commented Apr 4, 2018

Hello all, Same problem as bennburke:
patch-edid.rb:11:in

': undefined method[]' for nil:NilClass (NoMethodError)
Any suggestion?
Many thanks for your support

@MrtnGrdnr

This comment has been minimized.

Copy link

commented Apr 5, 2018

I have changed a lot of things & want to remove the patch, is there a command I can use to do this?
many thanks in advance

@kelvin22

This comment has been minimized.

Copy link

commented Apr 30, 2018

@MacMiniUser2017 instructions was previously working on Sierra, but after upgrading to High Sierra 10.13.4 it has reset back to original resolutions, and repeating the instructions doesn't work.

@cron13

This comment has been minimized.

Copy link

commented Jun 17, 2018

hi, it is possible to make script like this one, that enable 5.1 sound and 120hz/200hz mode on external tv that connected via hdmi?

@yarnball

This comment has been minimized.

Copy link

commented Oct 15, 2018

Hi, on Mojava (10.14) there is no /Overrides folder inside of Displays.

Is it possible to work on 10.14? Cheers

@mvtorres

This comment has been minimized.

Copy link

commented Oct 27, 2018

Hi, on Mojava (10.14) there is no /Overrides folder inside of Displays.

Is it possible to work on 10.14? Cheers

Its now in /System/Library/Displays/Contents/Resources/Overrides/

@yverbytskyi

This comment has been minimized.

Copy link

commented Dec 25, 2018

Made alive my HP LP2475w, connecting to MBP2018
For High Sierra path is just the same as for Mojave - /System/Library/Displays/Contents/Resources/Overrides/
So, what i've done:

  1. @maurei Even with sudo, any write operations will not be permitted. To fix this, reboot in recovery mode (cmd+r during reboot), under utils, open up the terminal. Do csrutil disable. Reboot, and run the script in the relocated folder.
  2. @antwake for those who have no output when running the script (like @oliviergilloire ) be sure that the file (patch-edid.rb) isn't empty.
    I had to download it manually and copy/paste it in /System/Library/Displays/Contents/Resources/Overrides
  3. sudo ruby patch-edid.rb
  4. Reconnect monitor vs reboot
  5. It really worked) Thanks all
@ionut-movila

This comment has been minimized.

Copy link

commented Jan 3, 2019

I can confirm this works really great.

Tested on a Hackintosh configuration with AMD RX-560 video card, running macOS 10.13.6 High Sierra.
My display is LG TV 4K 50UK6950.

After upgrading to 10.13.6 I was able to get 4k@60Hz and with this script also chroma 4:4:4 that is really great for text readability.

Chroma test here, last two lines: http://i.rtings.com/images/test-materials/2017/chroma-444.png

No need to look further for other solutions, like paid one SwitchResX that did NOT work for me.

To test refresh rate go here: https://www.testufo.com/framerates#count=3&background=stars&pps=3840

Even if the system report does not show 60Hz, using the link above I can confirm it does output 60Hz.

As for HDMI cable no need to use a special one, I think mine it's an old one with nothing special about HDMI 2.0 support.

But I was able to tell that 4k@60Hz with chroma 4:4:4 does work with this video card + TV display + cable because it did work first on Windows 10.

@haiqibian

This comment has been minimized.

Copy link

commented Feb 28, 2019

I tried all the way above, but I only got the highest resolution 1920x1080. How to get higher resolution 2560x1440? I am using MacBook pro Mini Displayport to HDMI.

Thanks a lot

@polyh3dron

This comment has been minimized.

Copy link

commented May 11, 2019

On a 2017 MacBook Pro running Mojave I’m getting an “Operation not permitted” error when running this script even after disabling csrutil, and giving disk access to terminal. This also just worked for me on another identical model MacBook Pro. Any idea what I can do? On the machine it worked on, I didn’t even need to give terminal full disk access, so I’m wondering if some other tweak I did to my settings somewhere along the way was what allowed me to run the script properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.