Command Line Methods to Toggle and Rotate Monitors on Ubuntu 24.04 (Wayland)
In Ubuntu Desktop Administration and Linux Display Management, the transition from X11 to Wayland has rendered the classic xrandr command ineffective for most configuration tasks. For users on Ubuntu 24.04 LTS, managing a rotated monitor—specifically disconnecting and then reconnecting it with the correct orientation via terminal—requires modern tools that interface with the Mutter compositor's D-Bus API.
1. The Primary Tool: gnome-monitor-config
The most robust way to manage displays in a GNOME Wayland session is gnome-monitor-config. This utility allows you to "set" a specific display configuration, effectively turning monitors off by omitting them or turning them on by defining their parameters.
How to Disconnect (Disable) a Monitor
To "disconnect" a secondary monitor while keeping your primary active, you must "set" a configuration that only includes the primary display. First, find your connector names:
gnome-monitor-config list
If your primary is DP-1 and your rotated secondary is HDMI-1, disable the secondary by only setting the primary:
gnome-monitor-config set -LpM DP-1 -m 1920x1080@60
How to Reconnect and Rotate
To reconnect the HDMI-1 monitor with a 90-degree rotation (Portrait), you must define the coordinates and the transform flag:
gnome-monitor-config set -LpM DP-1 -m 1920x1080@60 -LM HDMI-1 -t left -x 1920
- -t left: Rotates the monitor 90 degrees counter-clockwise.
- -x 1920: Positions the second monitor to the right of the first.
2. The xrandr-like Alternative: gnome-randr
For those who prefer xrandr syntax, the gnome-randr.py script is a popular community tool that translates classic commands into Wayland-compatible D-Bus calls. This is often the best choice for Ubuntu Categories users who want to reuse old scripts.
- Disconnecting:
python3 gnome-randr.py --output HDMI-1 --off - Reconnecting with Rotation:
python3 gnome-randr.py --output HDMI-1 --auto --rotate left --right-of DP-1
3. Comparison of Command Line Methods
Choosing the right method depends on whether you are using the default GNOME environment or a wlroots-based compositor (like Sway) on Ubuntu.
| Method | Target Compositor | Best For |
|---|---|---|
| gnome-monitor-config | GNOME / Mutter | Precise multi-monitor "profiles" and layouts. |
| gnome-randr.py | GNOME / Mutter | Users transitioning from X11 scripts. |
| wlr-randr | Sway / Wayfire | Lightweight, wlroots-compatible environments. |
4. Troubleshooting Rotation "Hangs"
In 2026, a common issue occurs when a monitor is reconnected via CLI but the Gnome Shell fails to redraw the workspace at the new aspect ratio. If the screen goes black or the orientation is wrong:
- Force a Refresh: Toggle the visibility status twice (Off, then On).
- Check logical-monitors: Ensure your
~/.config/monitors.xmlisn't conflicting with your manual CLI commands. In some cases, deleting this file and letting the system regenerate it can fix persistent rotation bugs.
Conclusion
While Wayland on Ubuntu 24.04 does not support the legacy xrandr tool for direct display changes, utilities like gnome-monitor-config provide even more granular control once you master the syntax. By defining logical monitor layouts that include -t rotation flags, you can automate the disconnection and reconnection of specialized vertical displays. For success in 2026, remember that the "set" command is an atomic operation—it applies the entire state of all monitors at once, rather than toggling them individually.
Keywords
Ubuntu 24.04 Wayland rotate monitor command line, gnome-monitor-config disable display, disconnect second monitor terminal ubuntu, wayland xrandr equivalent gnome, rotate screen linux terminal wayland, enable monitor cli ubuntu 2026, gnome-randr portrait mode command, multiple monitor script ubuntu wayland.
