How to programmatically rotate the screen in Gnome 3.28 (Wayland)

gnomewayland

I know how to rotate the screen in Xorg using xrandr or in Wayland using the gnome-control-center GUI, but is there a way to do it in Wayland using a command line interface or an API call ?

Context: I have a convertible laptop which is not supported by iio-sensor-proxy, and I would like to use a script or shortcut to quickly rotate the screen. Going back to Xorg is not an option.

Best Answer

A partial solution is to set the rotate-monitor key to some keybinding using gsettings or dconf-editor.

For instance, the following command will cause Ctrl+F8 to rotate the screen counterclockwise:

$ gsettings set org.gnome.mutter.keybindings rotate-monitor "['XF86RotateWindows', '<Control>F8']"

This does not allow the user to specify the target orientation, but only to rotate the screen until the desired orientation is reached.

Related Question