Search code examples
macosswiftcore-graphics

permanently modifying RGB gamma table


The following script sets a custom gamma table for the current display. It works for about a second before the screen resets to its default profile.

#!/usr/bin/swift

import CoreGraphics

var redTable: [CGGammaValue] = [0, 0]
var greenTable: [CGGammaValue] = [1, 0]
var blueTable: [CGGammaValue] = [0, 1]

CGSetDisplayTransferByTable(CGMainDisplayID(), 2, &redTable, &greenTable, &blueTable)

sleep(5)

What causes this reset without me calling CGDisplayRestoreColorSyncSettings() directly? How would I go about permanently adjusting the gamma table?


Solution

  • OK, found it. I was running flux which reconfigured the display profile every second or so. Quitting the app fixed it.