Ubuntu Xrandr portrait mode screen in VMware 1050 x 1680

I received a replacement monitor yesterday – already ancient (possibly 10-years old?) but very good quality. £35 including delivery. A SyncMaster 2043bw. It seemed appropriate for the space-constraints of where I’m placing it to use it in portrait mode. Especially for coding.

VMware has always been my virtualisation choice, and currently this particular WordPress site is running in a LAMP set-up … an Ubuntu 16.04 VM. (Pending transition to an Alpine/nginx Docker image). Unfortunately I don’t know how to set the resolution correctly in Ubuntu. It has VMware tools installed. The virtual graphics card looks to be installed. In display-settings for the VM, I unchecked “use host settings” and made sure maximum resolution constraints were generous. Either way, as VMware Workstation is already oriented correctly in the host, the Ubuntu guest doesn’t need to rotate. The correct resolution setting would be 1050×1680.

Admittedly I automatically chose 50Hz (being in the UK) … though really I think I ought to have picked 60. Not sure if that is responsible for the 6-pixel difference though? [Update: tried later with 60 … no difference]. I’m still not that familiar with Linux despite increasing practice with Raspbian and Ubuntu in particular. What am I doing wrong?

And, later, I tried again but making sure I replaced 1056 in the mode-line entirety with 1050 … but that actually blanked the display and I had to restart from VMware Workstation.

Found a solution!

And to make it persistent I made an executable .xprofile in my home directory (not setting an output, as it seems it remembers what mode it was last in … the mode just needs to exist!):

Hmmm – not sure if I needed sudo since of course just being in the x-session should mean xrandr having the right permissions, right? No time to mess about any more – it works … other things to move-on to.