Invert screen output vertically and horizontally on linux

Introduction

Due to various reasons, it was necessary to invert the output to the display. (The point is that it is reflected in the mirror) However, even if I searched, I could only find a way to rotate the screen, but I could not find a way to flip it at all, so I made a note.

What you can do with this article

--Invert the output to the display up / down, left / right, or both --Rotate the output to the display up / down, left / right (bonus)

Even if I check it, it does not come out, and I can not set it with GUI, so I will write first from the method of inverting the output. (It seems that there are many people who are overwhelmingly in trouble here)

environment

$ uname -a
Linux kali 4.18.0-kali2-amd64 #1 SMP Debian 4.18.10-2kali1 (2018-10-09) x86_64 GNU/Linux

I have only verified it on debian. I'm sorry if it doesn't work otherwise.

Invert screen output

The method is simple and at the terminal

$ xrandr -x

Just hit.

For externally connected displays

$ xrandr
Screen 0: minimum 320 x 200, current 2166 x 768, maximum 16384 x 16384
eDP connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1366x768      60.00*+  48.00  
   1280x720      60.00  
   1024x768      60.00  
   800x600       60.00  
   640x480       60.00  
HDMI-A-0 connected 800x480+1366+0 inverted (normal left inverted right x axis y axis) 255mm x 255mm
   800x480       59.98*+
   640x480       75.00    72.81    60.00    59.94  
   720x400       70.08  
DisplayPort-0 disconnected (normal left inverted right x axis y axis)

After checking the name of the display with (here, the part of eDP and HDMI-A-0 corresponds to the name)

$ xrandr --output HDMI-A-0 --reflect x

Then you can flip the X (left and right) of the display named HDMI-A-0.

Command summary

If it's the main display

#Flip horizontal
$ xrandr -x
#flip upside down
$ xrandr -y

#Up / down / left / right inversion combines the above two
$ xrandr -x
$ xrandr -y

If you want to adapt the settings to an external display (HDMI-A-0 in this case)

#Flip horizontal
$ xrandr --output HDMI-A-0 --reflect x
#flip upside down
$ xrandr --output HDMI-A-0 --reflect y
#Up / down / left / right
$ xrandr --output HDMI-A-0 --reflect xy
#Undo
$ xrandr --output HDMI-A-0 --reflect normal

Rotate screen output

For the time being, the rotation is also explained (although this can also be done with the GUI)

#Rotate up and down
$ xrandr -o inverted
#Vertical orientation with left as the apex
$ xrandr -o left
#Vertical orientation with the right apex
$ xrandr -o right
#Undo
$ xrandr -o normal

If you want to adapt the settings to an external display

#Rotate up and down
$ xrandr --output HDMI-A-0 --rotate inverted
#Vertical orientation with left as the apex
$ xrandr --output HDMI-A-0 --rotate left
#Vertical orientation with the right apex
$ xrandr --output HDMI-A-0 --rotate right
#Undo
$ xrandr --output HDMI-A-0 --rotate normal

The display can be rotated by software.

Conclusion

xrandr is a god. I tried my best to find it, but it didn't come out, so I thought it was no good, but I was satisfied that it was surprisingly easy to solve. Maybe many people are worried about the same thing, so I hope this article is useful.

Recommended Posts

Invert screen output vertically and horizontally on linux
Recording and playback on Linux
[UE4] Build DedicatedServer on Windows and Linux
Install wsl2 and master linux on windows
Install and launch k3s on Manjaro Linux
Install and Configure TigerVNC server on Linux
Learn sshd_config and authorized_keys (on Amazon Linux 2)
Replacing rmtrash on Mac and replacing rm on Linux
Specify the volume on linux and make a sound
Build Apache HTTP Server and Wildfly on Oracle Linux 8
MySQL installation on Aws Linux 2 and test data preparation
Compile and install MySQL-python for python2.7 on amazon linux
Install Docker on Arch Linux and run it remotely