Hi all,
I am working on configuring the GNOME desktop settings via D-Bus, specifically aiming to change the display resolution using org.gnome.Mutter.DisplayConfig
and the ApplyMonitorsConfig
method (I am aware that we can change the display resolution with xrandr, but I am restricted to dbus at the moment ). However, I am encountering a type conversion error when attempting to use the following code:
method_params = GLib.Variant('(uuba(iiduba(ssa{sv})))', (serial, 1, True, new_logical_monitors))
proxy.call_sync('ApplyMonitorsConfig', method_params, Gio.DBusCallFlags.NONE, -1, None)
My full function is as follows
def change_resolution(width, height):
proxy = get_display_config_interface()
current_state = proxy.call_sync('GetCurrentState', None, Gio.DBusCallFlags.NONE, -1, None)
serial, monitors, logical_monitors, properties = current_state.unpack()
new_logical_monitors = []
for monitor in logical_monitors:
# Unpack existing monitor configuration
x, y, scale, transform, primary, monitor_spec = monitor[:6]
if primary:
current_mode = monitor_spec[0][1]
new_mode = (current_mode[0], width, height, current_mode[3]) # New mode with current refresh rate
new_monitor_config = (x, y, scale, transform, primary, monitor_spec)
new_logical_monitors.append(new_monitor_config)
# Pack the method parameters into GLib.Variant
method_params = GLib.Variant('(uuba(iiduba(ssa{sv})))', (serial, 1, True, new_logical_monitors))
# Apply new configuration
proxy.call_sync('ApplyMonitorsConfig',
method_params,
Gio.DBusCallFlags.NONE, -1, None)
change_resolution(800, 600)
Unfortunately, I am constantly hitting a type conversion error.
Since I have very little experience with this topic, I’d appreciate it if someone could provide me with a simple example or point me to the right documentation. I searched online but didn’t recognize anything particularly useful.
Thanks in advance!