It all started with this toot from Aurynn.
do I just need to put one screen in portrait mode?
In the past I had experimented with using portrait displays for reading and programming. The ability to display large amount of text is certainly appealing.
Boring
But is this the most optimal display for software development? Lets evaluate
Rotation | Advantages | Disadvantages |
---|---|---|
0° | Works with most applications. Video content is usually in wide format | Websites and documents usually end up with a lot of whitespace and padding around them |
90° | Great for text documents - can read down like a book page | Movies don’t display well. Viewing angle problems |
Here you might think we might done. But there are soooooo many more angles we can try. This is a little tricky on macOS and Windows but on Linux we have all the freedom we need.
Odd but ok.
We have a little tool called xrandr
(x resize and rotate). We can use it to rotate the screen around to any angle we want. In practice I couldn’t get this to work on my MacBook. My desktop on the otherhand it had no problems. So lets try a few out.
1° - notice the menu bar disappearing to the right
45° - I run out of space
Rotation | Advantages | Disadvantages |
---|---|---|
1° | Handy if your desk is on a slight slope | fonts render a little weird |
45° | Middle ground between vertical and horizontal | doesn’t fit well with non square aspect ratios |
One neat thing about 45° is that it gives us pretty close to the diagonal. But not on my ultra wide. Due to maths, the amount we’d need to rotate is based on the angle of a triangle which match the aspect ration of the screen we are using. This ends up being about 22° for a 21:9 ratio.
The perfect rotation
22° - Perfect
Rotation | Advantages | Disadvantages |
---|---|---|
22° | Longest line length! | Webcam starts sliding away |
So this here I think is the best monitor orientation for software development. It provides the longest line lengths and no longer need to worry about that pesky 80 column limit.
How do I do this?
First off, I could only get this to work in xorg - no wayland support yet. xrandr --output HDMI-3 --transform lots of numbers here
takes a transformation matrix thats used to position the screen. We can use that to rotate the display.
The basic syntax that we need for rotating and shifting is this
cos(x),-sin(x),shift_left,sin(x),cos(x),shift_up,0,0,1
Some examples
# these won't shift / center the display as I don't know the resolution
#-0.1
xrandr --output HDMI-3 --transform 0.999998476913288,0.00174532836589831,0,-0.00174532836589831,0.999998476913288,0,0,0,1
#1
xrandr --output HDMI-3 --transform 0.999847695156391,-0.0174524064372835,0,0.0174524064372835,0.999847695156391,0,0,0,1
#45
xrandr --output HDMI-3 --transform 0.707106781186548,-0.707106781186548,0,0.707106781186548,0.707106781186548,0,0,0,1
#22
xrandr --output HDMI-3 --transform 0.927183854566787,-0.374606593415912,0,0.374606593415912,0.927183854566787,0,0,0,1
Calculator
This little javascript calculator should generate the xrandr command for given inputs
Enjoy.