Change only one display orientation from terminal

Solution 1:

Strange, but I found answer first!

You use

$ xrandr --output $monitorName --rotate $direction

where $monitorName can be found in output of

$ xrandr

and $direction is left for counter-clockwise or right for clockwise.

Edit: Using grep, it is possible to write a script like this:

#!/bin/bash

screen="HDMI1"

descr=$(xrandr | grep "$screen")
if echo "$descr" | grep disconnected
then
        echo "No $screen connected"
        exit 1
fi

alt="left"
if echo "$descr" | grep --quiet -P "^[^(]*$alt"
then
        rotate="normal"
else
        rotate="$alt"
fi
xrandr --output $screen --rotate $rotate 

which actually switches orientation of monitor storaged in $screen variable, and $alt is the alternative orientation.

Solution 2:

You'll need to use xrandr for that.

xrandr -o $orientation

Where $orientation is left, right, inverted, or normal.

You can select the display you want to rotate with the --display option.