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.
So long as you have one screen the following would be fine on an Ubuntu based system. Xrandr -o left to rotate to the left, xrandr -o right to rotate to the right, xrandr -o normal to go back to a normal screen, xrandr -o inverted to flip the screen upside down.
AgmenorAgmenor7,6661414 gold badges5757 silver badges9797 bronze badges
4 Answers
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.
roadmrroadmr28.1k55 gold badges6666 silver badges8080 bronze badges
Vergadin TheDwarfVergadin TheDwarf
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:
Vincent GerrisVincent Gerris
I wrote a shell script to do this. (Requires xrandr grep awk)
If you like one-liners:
derHugo2,36933 gold badges1616 silver badges3434 bronze badges
Alexx RocheAlexx Roche
Not the answer you're looking for? Browse other questions tagged display or ask your own question.
PermalinkJoin GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
Cannot retrieve contributors at this time
#!/bin/bash |
# Rotate the Microsoft Surface Pro touchscreen input |
# Usage: rotate [clockwise|counter-clockwise|normal|inverted|left|right] |
# The script will rotate the screen clockwise by default |
matrix() { |
declare -A dict=( |
['normal']='1 0 0 0 1 0 0 0 1' |
['inverted']='-1 0 1 0 -1 1 0 0 1' |
['left']='0 -1 1 1 0 0 0 0 1' |
['right']='0 1 0 -1 0 1 0 0 1' |
) |
echo'${dict['$1']}' |
} |
rotate() { |
M=$(matrix '$1') |
PROP='Coordinate Transformation Matrix' |
DEVICES=$(pointerID) |
xrandr -o $1 |
foridin$DEVICES;do xinput set-prop $id'$PROP'$M;done; |
notify-send |
'The system's display and touch-screen input have been rotated to $1' |
'Pointer device ID(s): $(echo $DEVICES| tr '''n'| sort -n | |
sed ':a;N;$!ba;s/n/, /g')' |
} |
clockwise() { |
declare -A dict=( |
['normal']='right' |
['inverted']='left' |
['left']='normal' |
['right']='inverted' |
) |
echo'${dict['$1']}' |
} |
counterClockwise() { |
declare -A dict=( |
['normal']='left' |
['inverted']='right' |
['left']='inverted' |
['right']='normal' |
) |
echo'${dict['$1']}' |
} |
currentRotation() { |
INFO='$(xrandr -q --verbose | grep LVDS1)' |
if [ '$(echo $INFO| cut -d'' -f 3)'='primary' ]; |
then |
echo'$(echo $INFO| cut -d'' -f 6)' |
else |
echo'$(echo $INFO| cut -d'' -f 5)' |
fi |
} |
pointerID() { |
echo'$(xinput --list | grep pointer | cut -f 2 | cut -d= -f 2)' |
} |
if [ '$1'='' ] || [ '$1'='clockwise' ]; |
then |
rotate '$(clockwise '$(currentRotation)')' |
elif [ '$1'='counter-clockwise' ]; |
then |
rotate '$(counterClockwise '$(currentRotation)')' |
else |
rotate '$1' |
fi |
Copy lines Copy permalink