allow scaling with resolution
This commit is contained in:
@@ -13,11 +13,6 @@ https://gitlab.gnome.org/GNOME/mutter/blob/master/src/org.gnome.Mutter.DisplayCo
|
|||||||
import dbus
|
import dbus
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
|
||||||
scaling_factor = float(sys.argv[1])
|
|
||||||
except IndexError:
|
|
||||||
scaling_factor = 1
|
|
||||||
|
|
||||||
namespace = "org.gnome.Mutter.DisplayConfig"
|
namespace = "org.gnome.Mutter.DisplayConfig"
|
||||||
dbus_path = "/org/gnome/Mutter/DisplayConfig"
|
dbus_path = "/org/gnome/Mutter/DisplayConfig"
|
||||||
|
|
||||||
@@ -46,13 +41,50 @@ for mode in connected_monitors[0][1]:
|
|||||||
if mode[6].get("is-current", False):
|
if mode[6].get("is-current", False):
|
||||||
current_mode = mode[0]
|
current_mode = mode[0]
|
||||||
|
|
||||||
current_mode = dbus.String("1920x1080@59.999")
|
|
||||||
updated_connected_monitors = [[connector, current_mode, {}]]
|
|
||||||
|
|
||||||
x, y, scale, transform, primary, monitors, props = logical_monitors[0]
|
x, y, scale, transform, primary, monitors, props = logical_monitors[0]
|
||||||
scale = scaling_factor
|
available_resolutions = [
|
||||||
|
str(item)
|
||||||
|
for item in map(lambda item: f"{item[1]}x{item[2]}", connected_monitors[0][1])
|
||||||
|
]
|
||||||
|
available_resolutions = sorted(
|
||||||
|
set(available_resolutions), key=lambda item: int(item.split("x")[0]), reverse=True
|
||||||
|
)
|
||||||
|
|
||||||
monitor_config = [[x, y, scale, transform, primary, updated_connected_monitors]]
|
try:
|
||||||
|
wanted_resolution = str(sys.argv[1])
|
||||||
|
except IndexError:
|
||||||
|
print("Desired resolution not provided. Example: `./display_scale.py 1920x1080`")
|
||||||
|
print("Available resolutions are:\n" + "\n".join(available_resolutions))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
wanted_scale = 1
|
||||||
|
try:
|
||||||
|
wanted_scale = float(sys.argv[2])
|
||||||
|
except IndexError:
|
||||||
|
print("Desired scale not provided. Example: `./display_scale.py 1920x1080 2`")
|
||||||
|
print("Defaulting to a scale of 1")
|
||||||
|
|
||||||
|
matching_resolutions = [
|
||||||
|
item
|
||||||
|
for item in filter(
|
||||||
|
lambda item: wanted_resolution in item[0], connected_monitors[0][1]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
try:
|
||||||
|
matched_resolution = matching_resolutions[0][0]
|
||||||
|
except IndexError:
|
||||||
|
print("Desired resolution not available.")
|
||||||
|
print("Available resolutions are:\n" + "\n".join(available_resolutions))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print(
|
||||||
|
f"Found {len(matching_resolutions)} matching resolutions."
|
||||||
|
f"Using {matched_resolution} scaled by {wanted_scale}."
|
||||||
|
)
|
||||||
|
updated_connected_monitors = [[connector, matched_resolution, {}]]
|
||||||
|
|
||||||
|
monitor_config = [[x, y, wanted_scale, transform, primary, updated_connected_monitors]]
|
||||||
|
|
||||||
# Change the 1 to a 2 if you want a "Revert Settings / Keep Changes" dialog
|
# Change the 1 to a 2 if you want a "Revert Settings / Keep Changes" dialog
|
||||||
interface.ApplyMonitorsConfig(serial, 1, monitor_config, {})
|
interface.ApplyMonitorsConfig(serial, 1, monitor_config, {})
|
||||||
|
|||||||
Reference in New Issue
Block a user