Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 16398  / 2 Years ago, wed, july 13, 2022, 11:55:25

I am starting to work with 2 displays on Ubuntu. One of them is rotateable, so I can use it easily in both landscape and portrait mode. But I world prefer to have ability to change orientation setting (which could be found in System Settings->Desktop) from terminal or script on one display but don't rotate other one.



I am pretty sure it is possible via xrandr!


More From » display

 Answers
3

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.


[#21969] Thursday, July 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ainubt

Total Points: 496
Total Questions: 98
Total Answers: 126

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
;