Skip to content

Instantly share code, notes, and snippets.

@MethodGrab
Last active November 16, 2022 20:54
Show Gist options
  • Save MethodGrab/ef8d254f469bc85b4d3e5fad3d37b74e to your computer and use it in GitHub Desktop.
Save MethodGrab/ef8d254f469bc85b4d3e5fad3d37b74e to your computer and use it in GitHub Desktop.
A fix for blurry text on external displays in macOS & OS X

macOS External Display Fix

A fix for blurry text on external displays in macOS & OS X.

  1. Run the patch (src) which will create a new directory in the CWD called DisplayProductID-YYYY:

    ruby ./patch-edid.rb
  2. Reboot into recovery mode (hold down CMD-R while rebooting)

  3. Open Terminal from the Utilities menu
    NB: If you use FileVault, you will need to unlock & mount Macintosh HD before continuing:

    1. diskutil apfs list

    2. Find the volume identifier for Macintosh HD:

      APFS Volume Disk (Role):  disk1s1 (No specific role) // `disk1s1` is the volume identifier
      Name:                     Macintosh HD (Case-insensitive)
      Mount Point:              /
      Capacity Consumed:        250GB
      Encrypted:                Yes
    3. diskutil apfs unlockVolume /dev/volume_identifier where volume_identifier is the one shown in the diskutil listing

    4. After unlocking the disk with an approved FileVault user, Macintosh HD will now be mounted at /Volumes/Macintosh HD

  4. Copy the patch dir to /System/Library/Displays/Contents/Resources/Overrides/[1], I reccomend backing up any existing directory if it exists for your display:
    XXXX is the suffix of the folder the patch script created
    YYYY is the suffix of the file it created
    /Volumes/Macintosh\ HD/Users/me/Downloads is the path patch-edid.rb was run in:

    1. cd /Volumes/Macintosh\ HD/System/Library/Displays/Contents/Resources/Overrides/
    2. mv DisplayVendorID-XXXX DisplayVendorID-XXXX-BACKUP
    3. mkdir DisplayVendorID-XXXX
    4. cp /Volumes/Macintosh\ HD/Users/me/Downloads/DisplayVendorID-XXXX/DisplayProductID-YYYY ./DisplayVendorID-XXXX
  5. That's it! Reboot back into normal mode and enjoy correct colours!

Notes

  • [1]: This path is for OS X El Capitan, macOS Sierra & macOS Catalina.
  • Disabling System Integrity Protection (SIP) is not required in macOS Catalina.

Sources

#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
productids=data.scan(/DisplayProductID.*?([0-9]+)/i).flatten
displays = []
edids.each_with_index do |edid, i|
disp = { "edid_hex"=>edid, "vendorid"=>vendorids[i].to_i, "productid"=>productids[i].to_i }
displays.push(disp)
end
# Process all displays
if displays.length > 1
puts "Found %d displays! You should only install the override file for the one which" % displays.length
puts "is giving you problems.","\n"
end
displays.each do |disp|
# Retrieve monitor model from EDID data
monitor_name=[disp["edid_hex"].match(/000000fc00(.*?)0a/){|m|m[1]}.to_s].pack("H*")
if monitor_name.empty?
monitor_name = "Display"
end
puts "found display '#{monitor_name}': vendorid #{disp["vendorid"]}, productid #{disp["productid"]}, EDID:\n#{disp["edid_hex"]}"
bytes=disp["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" % disp["vendorid"]) rescue nil
f = File.open("DisplayVendorID-%x/DisplayProductID-%x" % [disp["vendorid"], disp["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>#{monitor_name} - forced RGB mode (EDID override)</string>
<key>IODisplayEDID</key>
<data>#{Base64.encode64(bytes.pack('C*'))}</data>
<key>DisplayVendorID</key>
<integer>#{disp["vendorid"]}</integer>
<key>DisplayProductID</key>
<integer>#{disp["productid"]}</integer>
</dict>
</plist>"
f.close
puts "\n"
end # displays.each
@grovolis
Copy link

Hey is this still relevant to Big Sur?

@gokulprathin8
Copy link

Hey is this still relevant to Big Sur?

+1

@MethodGrab
Copy link
Author

Hey is this still relevant to Big Sur?

I created a repository for this that includes updated instructions for Big Sur & Monterey:
https://github.com/MethodGrab/macos-external-display-fix

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