A Python utility to programmatically set individual display scaling factors for multi-monitor setups in GNOME (via D-Bus).
This script is particularly useful for users who need to toggle scaling frequently or want to automate their display configuration without using the GNOME Settings GUI.
- Per-monitor scaling: Assign specific scaling factors (e.g., 1.0, 1.25, 2.0) to different displays.
- D-Bus Integration: Directly communicates with
org.gnome.Mutter.DisplayConfig. - Safe Execution: Uses the system's Python 3 to ensure
dbuslibrary availability.
- GNOME Desktop Environment (Mutter window manager).
- Python 3 with
python3-dbusinstalled (usually pre-installed on Ubuntu/Fedora).
Before running the script, you need to identify your monitor connector names and define your desired scaling in the SCALE_MAP dictionary within set_scale_multi.py.
Run the following command in your terminal:
xrandr --query | grep " connected"Common names are eDP-1 (internal laptop display), HDMI-1, or DP-1.
Update the SCALE_MAP in the script:
SCALE_MAP = {
"eDP-1": 1.0, # Example: Internal Display
"HDMI-1-0": 2.0 # Example: External 4K Monitor
}Make the script executable and run it:
chmod +x set_scale_multi.py
./set_scale_multi.pyIf you encounter this error, your system (likely under X11) does not support different scaling factors per monitor nativelly.
Solution for Wayland users: Enable the experimental fractional scaling feature:
gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"Note: A logout/login or restart might be required.
Based on discussions and snippets from AskUbuntu and strycore's gist.