You are not logged in.

#1 2022-08-12 10:16:35

Lyxodius
Member
Registered: 2022-07-30
Posts: 15

[SOLVED] Set scaling in Cinnamon via command line

Is there a way to set the scaling for a display (100 %, 200%, etc.) via the command line instead of the display settings GUI?

Last edited by Lyxodius (2022-08-12 14:41:44)

Offline

#2 2022-08-12 11:24:01

seth
Member
Registered: 2012-09-03
Posts: 51,779

Re: [SOLVED] Set scaling in Cinnamon via command line

https://wiki.archlinux.org/title/HiDPI#GNOME
https://wiki.archlinux.org/title/HiDPI#GUI_toolkits
Does this tie into https://bbs.archlinux.org/viewtopic.php?id=278697 where we just explicitly disabled the fractional scaling because it stumbled over the nvidia viewport translation?

Online

#3 2022-08-12 11:43:57

Lyxodius
Member
Registered: 2022-07-30
Posts: 15

Re: [SOLVED] Set scaling in Cinnamon via command line

gsettings set org.cinnamon.settings-daemon.plugins.xsettings overrides "[{'Gdk/WindowScalingFactor', <1>}]"

Almost works. The only thing that doesn't scale down is the panel at the bottom.

And yes, it's related to the earlier thread. The only missing piece now is setting the scaling via script, too, so I can easily switch between 1024x768 and 3840x2160.

gsettings set org.cinnamon.desktop.interface scaling-factor 1

This doesn't seem to do anything, unfortunately. At least I cannot see any change.

Another thing that's interesting is that while the first command works, the change is not reflected in the display settings GUI, so I guess it's just an override of the setting there (as the command suggests)?
Which doesn't really matter as long as it works, of course.

Last edited by Lyxodius (2022-08-12 11:57:56)

Offline

#4 2022-08-12 11:49:33

seth
Member
Registered: 2012-09-03
Posts: 51,779

Re: [SOLVED] Set scaling in Cinnamon via command line

https://bbs.archlinux.org/viewtopic.php … 1#p2051421
=> org.cinnamon.desktop.interface ?

Online

#5 2022-08-12 11:52:04

Lyxodius
Member
Registered: 2022-07-30
Posts: 15

Re: [SOLVED] Set scaling in Cinnamon via command line

Ah, sorry, I edited my answer instead of putting in a new reply.
The org.cinnamon.desktop.interface setting doesn't seem to do anything, unfortunately.

Last edited by Lyxodius (2022-08-12 11:58:09)

Offline

#6 2022-08-12 12:09:34

seth
Member
Registered: 2012-09-03
Posts: 51,779

Re: [SOLVED] Set scaling in Cinnamon via command line

Does

gsettings set org.cinnamon.desktop.interface text-scaling-factor 1

have any impact and/or do values other than "1" do anything (eg. try "2", since fractional isn't an option)

Online

#7 2022-08-12 12:11:44

Lyxodius
Member
Registered: 2022-07-30
Posts: 15

Re: [SOLVED] Set scaling in Cinnamon via command line

Yes, it does in fact change the size of text.

Offline

#8 2022-08-12 14:40:04

Lyxodius
Member
Registered: 2022-07-30
Posts: 15

Re: [SOLVED] Set scaling in Cinnamon via command line

Using different sources on the web I put together a Python script that does exactly what I want:

scale.py

#!/usr/bin/python3
import sys
import dbus
bus = dbus.SessionBus()

display_config_well_known_name = "org.cinnamon.Muffin.DisplayConfig"
display_config_object_path = "/org/cinnamon/Muffin/DisplayConfig"

display_config_proxy = bus.get_object(display_config_well_known_name, display_config_object_path)
display_config_interface = dbus.Interface(display_config_proxy, dbus_interface=display_config_well_known_name)

serial, physical_monitors, logical_monitors, properties = display_config_interface.GetCurrentState()

new_scale = 2.0;

if len(sys.argv) > 1:
    new_scale = float(sys.argv[1])
else:
    for x, y, scale, transform, primary, linked_monitors_info, props in logical_monitors:
        if primary == 1:
            new_scale = 2.0 if (scale == 1.0) else 1.0 # toggle scaling for all screens between 1.0 and 2.0 of the primary monitor
            break;

updated_logical_monitors=[]
for x, y, scale, transform, primary, linked_monitors_info, props in logical_monitors:
    physical_monitors_config = []
    for linked_monitor_connector, linked_monitor_vendor, linked_monitor_product, linked_monitor_serial in linked_monitors_info:
        for monitor_info, monitor_modes, monitor_properties in physical_monitors:
            monitor_connector, monitor_vendor, monitor_product, monitor_serial = monitor_info
            if linked_monitor_connector == monitor_connector:
                for mode_id, mode_width, mode_height, mode_refresh, mode_preferred_scale, mode_supported_scales, mode_properties in monitor_modes:
                    if mode_properties.get("is-current", False): # ( mode_properties provides is-current, is-preferred, is-interlaced, and more)
                        physical_monitors_config.append(dbus.Struct([monitor_connector, mode_id, {}]))
                        if new_scale not in mode_supported_scales:
                            print("Error: " + monitor_properties.get("display-name") + " doesn't support that scaling value! (" + str(scale) + ")")
                        else:
                            print("Setting scaling of: " + monitor_properties.get("display-name") + " to " + str(new_scale) + "!")
    updated_logical_monitor_struct = dbus.Struct([dbus.Int32(x), dbus.Int32(y), dbus.Double(new_scale), dbus.UInt32(transform), dbus.Boolean(primary), physical_monitors_config])
    updated_logical_monitors.append(updated_logical_monitor_struct)

properties_to_apply = { "layout_mode": properties.get("layout-mode")}
method = 1 # 2 means show a prompt before applying settings; 1 means instantly apply settings without prompt
display_config_interface.ApplyMonitorsConfig(dbus.UInt32(serial), dbus.UInt32(method), updated_logical_monitors, properties_to_apply)

Short explanation:

You can use it like this: ./scale.py <scaling>
The scaling parameter is optional.
The scaling parameter is a number (e.g. 1, 2, 3.14 etc.).
If you don't provide the scaling parameter, it will look for the scaling on the primary screen.
If the current scaling is 2, the new scaling will be 1.
If the current scaling is 1, the new scaling will be 2.

Works like a charm!

Last edited by Lyxodius (2022-08-12 14:41:06)

Offline

Board footer

Powered by FluxBB