Skip to content

Instantly share code, notes, and snippets.

@saivert
Created October 24, 2021 14:14
Show Gist options
  • Save saivert/4810fe0d925c261514c898e74d187fd6 to your computer and use it in GitHub Desktop.
Save saivert/4810fe0d925c261514c898e74d187fd6 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import dbus
bus = dbus.SessionBus()
request_iface = 'org.gnome.Mutter.DisplayConfig'
DisplayConfig = bus.get_object(request_iface,
'/org/gnome/Mutter/DisplayConfig')
data = DisplayConfig.GetCurrentState(dbus_interface=request_iface)
print("List of monitors:")
for d in data[1]:
print ("Display: %s"%(d[2].get("display-name")))
print (" List of modes (* = current mode):")
for mode in d[1]:
print (" %dx%d %dHz "%(mode[1], mode[2], mode[3]), end='')
if mode[6].get("is-current"):
print (" *")
else:
print ("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment