How to set a reasonable VNC desktop resolution for remote development/use

One of the BIG issues I have had with Charlie, (and messing with the Raspberry Pi in general), is getting a remote desktop resolution that is useful.

Here are a couple of examples:

First:
This is what my desktop looks like when I have my 1360x768 “TV”/monitor hooked up to the primary HDMI port on my Pi-4, and then open a VNC connection to the 'bot:

What you see is a 1360x768 view of my desktop that matches the view on the monitor.

Now for the kicker - I shut down the machine, remove the HDMI connection, restart, and reconnect to the VNC desktop - and here’s what I get:

. . . what appears to be a 1024x768 display.

AND IT HAS BEEN DRIVING ME CRAZY! (er)

Even with a relatively large laptop screen, the display is too small and is difficult to read - even if I set the display to “125%” in VNC Viewer.

I have been working on figuring this out for eons.  I have tried everything from adding modeline statements to the vnc X-11 config file, changing values in the expert mode options, etc. etc. etc.

I have gone to every site imaginable - from the Raspberry Pi forums to the RealVNC site’s help documentation - Stack Overflow, Web searches, burning brown rice and sacrificing small rodents to the Computer Gods, you name it and I’ve tried it - at least three or four times - all to no avail.

Today I (think I have) figured it out.

I found an article that refers to setting a “headless screen resolution” where the normal display configuration dialog has a new setting - headless resolution - that is probably Bullseye or later only - Legacy doesn’t have it.

One of the things that was - incidentally - mentioned, (not the main topic), was the existence of a screen configuration utility, also known as the “Screen Layout Editor” which is in the main menu under “Preferences”


 
(If you don’t see it, select “Main Menu Editor” => Preferences and then check the box next to “Screen Configuration”)

Once you do this, you will see a screen configuration utility


 
This shows the display resolution set in raspi-config, if you’ve set one.  (Hint: Go set one for the resolution you want to use if you have not done that already.)

You can configure other resolutions by editing the settings-options-expert within the VNC options


 
There’s a setting called “randr”.  (Damned if I know - it doesn’t make sense to me either.)  You can give it a comma-separated list of resolutions and this will propagate to the Screen Configuration setup window.

You can select them and - if they are valid settings - the change will happen.  Clicking on the green arrow “applies” the setting and you then click “OK” to accept it.  (You might have to do that a couple of times.)

Finally!

I have a screen resolution that is reasonable, and does not depend on a monitor being attached!

There are probably other tricks you can do - different display resolutions, etc - but aside from what I have shown here, I have decided that close enough is close enough and I am leaving it alone!

2 Likes

Wow! And I thought my method was arduous.

raspi-config:
- DisplayOptions:Resolution:1920x1080  

sudo systemctl restart vncserver-x11-serviced.service
vncserver -kill :1
vncserver :1 -geometry 1920x1080 -depth 24 -Authentication VncAuth -Encryption PreferOff -SecurityTypes StandardUser

But I only connect headless.

2 Likes

I’ve just used ssh -X to connect to Finmark via my Linux laptop. When I’ve had to run a GUI program it opens the x window on the laptop, which seems to work fine. So I don’t bother recreating the whole desktop. That lets me run the robot w/o having to run a GUI locally.
/K

2 Likes

From the Raspberry Pi website at

Here’s how to create a virtual desktop on a headless system:

2 Likes