On Wayland, screen rotation is typically handled differently than on Xorg due to the differences in architecture and design between the two display servers. Wayland does not directly support screen rotation through tools like xrandr as Xorg does. This approuch is used for screen rotation on Wayland using the command line.
Run the following command to check the session type:
echo $XDG_SESSION_TYPE
# Output: wayland
sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build
Install as a local user (recommended):
pip3 install --user meson
Install as root:
sudo pip3 install meson
# Related errors: src/meson.build:3:8: ERROR: Dependency lookup for cairo with method 'pkgconfig' failed: Pkg-config for machine host machine not found. Giving up.
sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev
The following steps can be used to build gnome-monitor-config
$ meson build
$ cd build
$ meson compile
The output binary can be found in build/src/gnome-monitor-config
.
For usage details, run
# Path: gnome-monitor-config/build/src/gnome-monitor-config
$ ./gnome-monitor-config --help
Usage: ./src/gnome-monitor-config [OPTIONS...] COMMAND [COMMAND OPTIONS...]
Options:
-h, --help Print help text
Commands:
list List current monitors and current configuration
set Set new configuration
show Show monitor labels
Options for 'set':
-L, --logical-monitor Add logical monitor
-x, --x=X Set x position of newly added logical monitor
-y, --y=Y Set y position of newly added logical monitor
-s, --scale=SCALE Set scale of newly added logical monitor
-t, --transform=TRANSFORM Set transform (normal, left, right, flip)
-p, --primary Mark the newly added logical monitor as primary
-m, --mode Set the display resolution and refresh rate. ex: 1920x1080@60
-M, --monitor=CONNECTOR Add a monitor (given its connector) to newly added
logical monitor
-p, --primary Mark the newly added logical monitor as primary
--logical-layout-mode Set logical layout mode
--physical-layout-mode Set physical layout mode
When running this as a service or crontab script, it may be necessary to:
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
Start with gnome-monitor-config list
to get a list of available monitors and configurations.
$ gnome-monitor-config list
...
800x600@59.8614 [id: '800x600@59.861'] [preferred scale = 1 (1)]
720x576@50 [id: '720x576@50.000'] [preferred scale = 1 (1)]
Logical monitor [ 2560x1440+0+0 ], scale = 1, transform = left
DP-3
Logical monitor [ 3840x1600+1440+270 ], PRIMARY, scale = 1, transform = normal
DP-1
Max screen size: unlimited
For example to set a single display to a particular configuration:
$ gnome-monitor-config set -LpM DP-1 -t normal -m 3840x1600@143.998
This sets the display attached to DP-1
as the primary display
(specified with -p
) at 3840x1600@143.998
configuration with
a normal
orientation.
Similarly, to setup multple monitors. First use the list
command to get a
list of what is available, then simply:
$ gnome-monitor-config set -LM DP-3 -m 2560x1440@143.912 -t left -LpM DP-1 -m 3840x1600@143.998" -x 1440 -y 270 -t normal
This command sets the monitor attached to DP-3 at the starting point [0, 0],
configured at 2560x1440@143.912 and left transformed (portrait). Then the
next monitor on DP-1 is configured as the primary (-p
) with an x,y offset of
[1440, 270] relative to the first one with normal orientation. For getting the
correct y offset with multiple monitors, you can simple experiment with the value
to get an appropriate alignment.