How to rotate an external HDMI monitor on Ubuntu 16.04

If you have an external monitor like a DELL 24" IPS P2414H, one problem is that it doesn't recognize when it rotates.
I developed on bash an application to rotate the monitor.
You need identificate the name and resolution of your monitor. Just run:

xrandr | grep " connected" | grep -v primary
HDMI1 connected 1920x1080+1366+0 (normal left inverted right x axis y axis) 527mm x 297mm

As you see, my second monitor is identified as HDMI1 with 1920x1080 pixels as resolution.

This is the script:

#!/bin/bash
left=`xrandr | grep HDMI1 | grep -o left | wc | awk '{print $1}'`
if [ $left -eq 2 ] 
then
    xrandr --output HDMI1 --mode 1920x1080 --rotate normal
else
    xrandr --output HDMI1 --mode 1920x1080 --rotate left
fi

I filtered by left, because when I rotate my monitor always is to left.
You can change it to any other direction.
You can create a .desktop and use any of these images.


 

Enjoy it!

Comments

Popular posts from this blog

How to fix Android when developer options are not available for this user

Exception: Could not find a default OpenFlow controller in Mininet

v4l2: open /dev/video0: Permission denied