Change only one display orientation from terminal












3














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!










share|improve this question
























  • Is your question mainly on how to script it, or how to do it with xrandr? In the last case, you will find it here: askubuntu.com/a/171154/72216, but it can be made changeable / toggle with a key combination of course, but then the scripting is actually the question.
    – Jacob Vlijm
    Dec 21 '14 at 9:31












  • @JacobVlijm as I just found answer on my own from man. Thanks. I think that bash script with xrandr command inside will work, won't it?
    – Lapshin Dmitry
    Dec 21 '14 at 9:38










  • Absolutely. The nicest would be to toggle; make a script read from xrandr what is the current rotation of the second screen, set it to "the other option" under a shortcut key.
    – Jacob Vlijm
    Dec 21 '14 at 9:42






  • 1




    @JacobVlijm I did it, using basicly xrandr and grep.
    – Lapshin Dmitry
    Dec 21 '14 at 18:20
















3














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!










share|improve this question
























  • Is your question mainly on how to script it, or how to do it with xrandr? In the last case, you will find it here: askubuntu.com/a/171154/72216, but it can be made changeable / toggle with a key combination of course, but then the scripting is actually the question.
    – Jacob Vlijm
    Dec 21 '14 at 9:31












  • @JacobVlijm as I just found answer on my own from man. Thanks. I think that bash script with xrandr command inside will work, won't it?
    – Lapshin Dmitry
    Dec 21 '14 at 9:38










  • Absolutely. The nicest would be to toggle; make a script read from xrandr what is the current rotation of the second screen, set it to "the other option" under a shortcut key.
    – Jacob Vlijm
    Dec 21 '14 at 9:42






  • 1




    @JacobVlijm I did it, using basicly xrandr and grep.
    – Lapshin Dmitry
    Dec 21 '14 at 18:20














3












3








3


1





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!










share|improve this question















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!







display xrandr system-settings






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 20 '14 at 23:12

























asked Dec 20 '14 at 22:43









Lapshin Dmitry

173110




173110












  • Is your question mainly on how to script it, or how to do it with xrandr? In the last case, you will find it here: askubuntu.com/a/171154/72216, but it can be made changeable / toggle with a key combination of course, but then the scripting is actually the question.
    – Jacob Vlijm
    Dec 21 '14 at 9:31












  • @JacobVlijm as I just found answer on my own from man. Thanks. I think that bash script with xrandr command inside will work, won't it?
    – Lapshin Dmitry
    Dec 21 '14 at 9:38










  • Absolutely. The nicest would be to toggle; make a script read from xrandr what is the current rotation of the second screen, set it to "the other option" under a shortcut key.
    – Jacob Vlijm
    Dec 21 '14 at 9:42






  • 1




    @JacobVlijm I did it, using basicly xrandr and grep.
    – Lapshin Dmitry
    Dec 21 '14 at 18:20


















  • Is your question mainly on how to script it, or how to do it with xrandr? In the last case, you will find it here: askubuntu.com/a/171154/72216, but it can be made changeable / toggle with a key combination of course, but then the scripting is actually the question.
    – Jacob Vlijm
    Dec 21 '14 at 9:31












  • @JacobVlijm as I just found answer on my own from man. Thanks. I think that bash script with xrandr command inside will work, won't it?
    – Lapshin Dmitry
    Dec 21 '14 at 9:38










  • Absolutely. The nicest would be to toggle; make a script read from xrandr what is the current rotation of the second screen, set it to "the other option" under a shortcut key.
    – Jacob Vlijm
    Dec 21 '14 at 9:42






  • 1




    @JacobVlijm I did it, using basicly xrandr and grep.
    – Lapshin Dmitry
    Dec 21 '14 at 18:20
















Is your question mainly on how to script it, or how to do it with xrandr? In the last case, you will find it here: askubuntu.com/a/171154/72216, but it can be made changeable / toggle with a key combination of course, but then the scripting is actually the question.
– Jacob Vlijm
Dec 21 '14 at 9:31






Is your question mainly on how to script it, or how to do it with xrandr? In the last case, you will find it here: askubuntu.com/a/171154/72216, but it can be made changeable / toggle with a key combination of course, but then the scripting is actually the question.
– Jacob Vlijm
Dec 21 '14 at 9:31














@JacobVlijm as I just found answer on my own from man. Thanks. I think that bash script with xrandr command inside will work, won't it?
– Lapshin Dmitry
Dec 21 '14 at 9:38




@JacobVlijm as I just found answer on my own from man. Thanks. I think that bash script with xrandr command inside will work, won't it?
– Lapshin Dmitry
Dec 21 '14 at 9:38












Absolutely. The nicest would be to toggle; make a script read from xrandr what is the current rotation of the second screen, set it to "the other option" under a shortcut key.
– Jacob Vlijm
Dec 21 '14 at 9:42




Absolutely. The nicest would be to toggle; make a script read from xrandr what is the current rotation of the second screen, set it to "the other option" under a shortcut key.
– Jacob Vlijm
Dec 21 '14 at 9:42




1




1




@JacobVlijm I did it, using basicly xrandr and grep.
– Lapshin Dmitry
Dec 21 '14 at 18:20




@JacobVlijm I did it, using basicly xrandr and grep.
– Lapshin Dmitry
Dec 21 '14 at 18:20










2 Answers
2






active

oldest

votes


















4














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.






share|improve this answer



















  • 1




    nice, and it works!
    – Jacob Vlijm
    Dec 21 '14 at 18:32



















3














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.






share|improve this answer























  • --dsplay selects X server, not the monitor, does it?
    – Lapshin Dmitry
    Dec 21 '14 at 9:28











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f563809%2fchange-only-one-display-orientation-from-terminal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














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.






share|improve this answer



















  • 1




    nice, and it works!
    – Jacob Vlijm
    Dec 21 '14 at 18:32
















4














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.






share|improve this answer



















  • 1




    nice, and it works!
    – Jacob Vlijm
    Dec 21 '14 at 18:32














4












4








4






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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 21 '14 at 18:24

























answered Dec 21 '14 at 9:36









Lapshin Dmitry

173110




173110








  • 1




    nice, and it works!
    – Jacob Vlijm
    Dec 21 '14 at 18:32














  • 1




    nice, and it works!
    – Jacob Vlijm
    Dec 21 '14 at 18:32








1




1




nice, and it works!
– Jacob Vlijm
Dec 21 '14 at 18:32




nice, and it works!
– Jacob Vlijm
Dec 21 '14 at 18:32













3














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.






share|improve this answer























  • --dsplay selects X server, not the monitor, does it?
    – Lapshin Dmitry
    Dec 21 '14 at 9:28
















3














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.






share|improve this answer























  • --dsplay selects X server, not the monitor, does it?
    – Lapshin Dmitry
    Dec 21 '14 at 9:28














3












3








3






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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 3 '18 at 16:50









Zanna

50.2k13133241




50.2k13133241










answered Dec 20 '14 at 23:16









argarevarg

483




483












  • --dsplay selects X server, not the monitor, does it?
    – Lapshin Dmitry
    Dec 21 '14 at 9:28


















  • --dsplay selects X server, not the monitor, does it?
    – Lapshin Dmitry
    Dec 21 '14 at 9:28
















--dsplay selects X server, not the monitor, does it?
– Lapshin Dmitry
Dec 21 '14 at 9:28




--dsplay selects X server, not the monitor, does it?
– Lapshin Dmitry
Dec 21 '14 at 9:28


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f563809%2fchange-only-one-display-orientation-from-terminal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?