I am the lucky owner of a pivot monitor, which screen can be rotated (physically). What is the easiest way to make my display turn when I turn my monitor?
For the moment I first launch the 'Displays' app, and then change the settings and confirm. But this is in fact quite a laboured procedure, since I want to switch my orientation up to a few times per minute.
So is there an indicator for this, or equivalent? Can I set a keyboard shortcut that would launch a dedicated command? In fact I am thinking of something similar to the Windows program iRotate.
Go into Keyboard -> Shortcuts, select "Custom Shortcuts", and press "+" to add a new shortcut.
"Name" is a descriptive name for the action (i.e. "Rotate monitor"). In "Command" type the custom command to run when the shortcut is activated.
Once the shortcut is in the list, select its row, press ENTER, then the key combination you want to activate the shortcut. If there's a conflict, the shortcut manager will tell you so, and you can choose a different combination.
You can have shortcut to enable rotated display and another to bring it back to an upright position. You can even, if you're knowledgeable enough, write a command that maintains state and just toggles between upright/rotated.
Now, as for the command you need to use, it's probably xrandr:
The output parameter depends on which port your monitor is plugged into. To see what you currently have, type:
Mine says:
In this case my --output would be LVDS1, as all the others are disconnected.
Works great with
Here is a nice example on how to do it based on sensor input: https://linuxappfinder.com/blog/auto_screen_rotation_in_ubuntu
So basically try the above to identify the screen you want to see rotated. Depending on the model monitor there may be a sensor that sends a signal?
This works nicely for my Lenovo Yoga 2 11 with builtin rotation sensor and it moves the unity dock too.
The script:
and prerequisite for the sensors:
Slightly simpler variation of Vincent Gerris's answer based on sensor input:
I wrote a shell script to do this. (Requires xrandr grep awk)
If you like one-liners:
In addition to the script posted in derHugo's answer, On Kubuntu 20.10, I had to change it to
{print $5}
as well as using bash instead of plain sh. With those minor modifications, my script reads: