Skip to content

Instantly share code, notes, and snippets.

@martin-v
Created January 22, 2021 08:28
Show Gist options
  • Save martin-v/37f6bde1cf41ba71148ff4c2c7117d3e to your computer and use it in GitHub Desktop.
Save martin-v/37f6bde1cf41ba71148ff4c2c7117d3e to your computer and use it in GitHub Desktop.
Synchronize the gamma values on Gnome by majority vote
#!/usr/bin/env python3
import dbus
bus = dbus.SessionBus()
proxy = bus.get_object('org.gnome.Mutter.DisplayConfig',
'/org/gnome/Mutter/DisplayConfig')
iface = dbus.Interface(proxy, dbus_interface='org.gnome.Mutter.DisplayConfig')
resources = iface.GetResources()
serial = resources[0]
outputs = resources[2]
gamma = []
if len(outputs) != 3:
raise NotImplementedError('Can only handle 3 monitors')
for output in outputs:
gamma.append(iface.GetCrtcGamma(serial, output[2]))
if gamma[1] == gamma[2]:
correctGamma = gamma[1]
crtcToFix = outputs[0][2]
elif gamma[0] == gamma[2]:
correctGamma = gamma[0]
crtcToFix = outputs[1][2]
elif gamma[0] == gamma[1]:
correctGamma = gamma[0]
crtcToFix = outputs[2][2]
iface.SetCrtcGamma(serial, crtcToFix, correctGamma[0], correctGamma[1], correctGamma[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment