How to set up vertical screen on Ubuntu dual display

How to set up vertical screen on Ubuntu dual display

introduction

The author needs to use an external vertical screen display to type code and another main screen to view other content. However, Ubuntu’s native graphical settings panel does not have this adjustment function, so I use the command line to adjust it. The following is the adjustment method. , successfully tried on the laptop's built-in screen and HDMI external display.

Method steps

1. Query the currently existing display screen

xrandr

result:

hermanye@hermanye-Dell-G16-7630:~$ xrandr
Screen 0: minimum 320 x 200, current 4480 x 1600, maximum 16384 x 16384
eDP-1 connected primary 2560x1600+0+0 (normal left inverted right x axis y axis) 345mm x 215mm
   2560x1600     60.00*+  60.00  
   2560x1440     60.00  
   2048x1536     60.00  
   1920x1440     60.00  
   1856x1392     60.00  
   1792x1344     60.00  
   2048x1152     60.00  
   1920x1200     60.00  
   1920x1080     60.00  
   1600x1200     60.00  
   1680x1050     60.00  
   1400x1050     60.00  
   1600x900      60.00  
   1280x1024     60.00  
   1400x900      60.00  
   1280x960      60.00  
   1440x810      60.00  
   1368x768      60.00  
   1280x800      60.00  
   1280x720      60.00  
   1024x768      60.00  
   960x720       60.00  
   928x696       60.00  
   896x672       60.00  
   1024x576      60.00  
   960x600       60.00  
   960x540       60.00  
   800x600       60.00  
   840x525       60.00  
   864x486       60.00  
   700x525       60.00  
   800x450       60.00  
   640x512       60.00  
   700x450       60.00  
   640x480       60.00  
   720x405       60.00  
   684x384       60.00  
   640x360       60.00  
   512x384       60.00  
   512x288       60.00  
   480x270       60.00  
   400x300       60.00  
   432x243       60.00  
   320x240       60.00  
   360x202       60.00  
   320x180       60.00  
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-0 connected 1920x1080+2560+0 (normal left inverted right x axis y axis) 527mm x 296mm
   1920x1080     60.00*+  74.97    59.94    50.00  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DP-1-0 disconnected (normal left inverted right x axis y axis)

It can be seen from the results HDMI-1-0that the external screen needs to be rotated

2. Rotate the screen

rotate screen left

xrandr --output HDMI-1-0 --rotate left

Result: The external screen rotates normally to vertical screen

3. Auto-start at boot [not available after testing]

After testing, it cannot start automatically after booting. It may be due to incorrect setting time. It needs to be fully started before enabling it.

sudo touch /tmp/screen_rotate.sh  # Create bash script
sudo chmod 777 /tmp/screen_rotate.sh  # Grant permission
sudo echo "xrandr --output HDMI-1-0 --rotate left" >> /tmp/screen_rotate.sh  # Write to script
sudo mv /tmp/screen_rotate.sh /etc/init.d/
sudo update-rc.d screen_rotate.sh defaults 90
sudo reboot  # reboot

If you want to remove:
sudo update-rc.d -f <your_script.sh> remove

4. Manual activation at power-on

sudo touch ~/screen_rotate.sh  # Create bash script
sudo chmod 777 ~/screen_rotate.sh  # Grant permission
sudo echo "xrandr --output HDMI-1-0 --rotate left" >> ~/screen_rotate.sh  # Write to script
. ~/screen_rotate.sh

You can also try to put this script ~/.bashrcin and execute the rotation every time the terminal is started. After testing, it will only rotate once and not repeatedly.

echo "source ~/screen_rotate.sh" >> ~/.bashrc

Guess you like

Origin blog.csdn.net/m0_56661101/article/details/131372060