#!/usr/bin/python3 # This script sets the display scale factor to 2, for use on 4K displays where everything is too small without scaling. import dbus new_scale = 2.0 # https://gitlab.gnome.org/GNOME/mutter/-/blob/main/data/dbus-interfaces/org.gnome.Mutter.DisplayConfig.xml bus_name = "org.gnome.Mutter.DisplayConfig" object_path = "/org/gnome/Mutter/DisplayConfig" session_bus = dbus.SessionBus() display_config_object = session_bus.get_object(bus_name, object_path) display_config_intf = dbus.Interface(display_config_object, dbus_interface=bus_name) serial, physical_monitors, logical_monitors, properties = display_config_intf.GetCurrentState() current_mode_id = {} for ((connector, _, _, _), modes, monitor_properties) in physical_monitors: for (mode_id, width, height, rate, preferred_scale, supported_scales, mode_properties) in modes: if mode_properties.get("is-current", False): current_mode_id[connector] = mode_id scaled_logical_monitors = [ (layout_x, layout_y, new_scale, transform, primary, [ (connector, current_mode_id[connector], {}) for (connector, _, _, _) in monitors ]) for (layout_x, layout_y, scale, transform, primary, monitors, monitor_properties) in logical_monitors ] apply_properties = {} if "layout-mode" in properties and properties.get("supports-changing-layout-mode", False): apply_properties["layout-mode"] = properties["layout-mode"] method = 1 # temporary display_config_intf.ApplyMonitorsConfig(serial, method, scaled_logical_monitors, apply_properties)