A lightweight Python utility to watch and automatically reset GNOME display scaling when running under Wayland.
Resizing the window of a GNOME desktop environment running inside a VM on Wayland triggers a display reconfiguration. GNOME's Wayland compositor (Mutter) frequently defaults these new resolutions to a 100% scale regardless of the existing display scale setting.
This tool is irrelevant when running under X11, which doesn't support generic display scaling.
This script serves as a watchdog for display configurations. It listens for MonitorsChanged signals via the GNOME Mutter DBus API. When a change is detected, such as a VM window resize or physical display hotplug, it checks the current scale and resets to the specified target scale upon a mismatch.
- Reacts instantly to VM window resizes and display hotplugs.
- Can specify:
- Separate scaling factors for each display.
- A default scaling factor for any display not listed by name.
- Automatically "snaps" the preferred scale to the closest value supported by Mutter for each display's current resolution.
- Specifying a display in a mirror group will scale the entire group based on the supported scales of the first display in that group.
- Runs as a user systemd service that automatically starts on login.
- Named displays do not need to be present when the service starts.
- GNOME Desktop Environment (Wayland)
- Python 3
python3-gi(GObject Introspection)
-
Install the script: The provided service config will look for the script in
~/libexec.mkdir -p ~/libexec cp display-scale-reset.py ~/libexec/
-
Configure the systemd service: Open
display-scale-reset.servicefor editing and replace{{SCALE}}with the preferred scale configuration.Examples:
- Global scale:
--scale 1.25 - Per-display:
--scale eDP-1:1.25 --scale HDMI-1:1.0
- Global scale:
-
Install and start the service:
mkdir -p ~/.config/systemd/user/ cp display-scale-reset.service ~/.config/systemd/user/ systemctl --user daemon-reload systemctl --user enable display-scale-reset.service systemctl --user start display-scale-reset.service
Identify connected displays:
~/libexec/display-scale-reset.py --list-displaysExample output:
CONNECTOR SCALE PRIMARY
----------------------------------
eDP-1 1.25 Yes
HDMI-1 1.0 No
Virtual-1 1.25 No
Force apply a scale configuration and exit:
~/libexec/display-scale-reset.py --force-once --scale 1.25Watch for scale changes on all displays and set all to 150%:
~/libexec/display-scale-reset.py --scale 1.5Operate on only one display:
~/libexec/display-scale-reset.py --scale HDMI-1:1.25Custom scale for two displays with a default of 150% for any other display.
~/libexec/display-scale-reset.py --scale 1.5 --scale eDP-1:1.25 --scale HDMI-1:1.0This project is licensed under the MIT License - see the LICENSE file for details.