Geometry (screen resolution) option for TigerVNC

How do I enter geometry information into a TigerVNC .service file?

I tried these 3 things:

  1. Edit /usr/lib/systemd/system/vncserver@.service by inserting a geometry phrase, so the relevant line becomes:

ExecStart=/usr/bin/vncsession-start -geometry 1300x900 %i

On this, I also tried inverting the last two bits:

ExecStart=/usr/bin/vncsession-start -geometry %i 1300x900

And running xrandr and using one of the listed resolutions:

ExecStart=/usr/bin/vncsession-start -geometry 1280x960 %i

  1. Create a new .service file, i.e. myserver@.service or myserver@:1.service, with the same contents as above, and start with:

sudo systemctl start myserver@:1

  1. Re-naming the new .service file to myserver.service and starting with:

sudo systemctl start myserver

All these gave me an error:

Job for vncserver@:1.service failed because the control process exited with error code.
See “systemctl status vncserver@:1.service” and “journalctl -xeu vncserver@:1.service” for details.

I don’t believe the 3 variants made much difference. I believe the offending element is the insertion of the phrase -geometry 1300x900.

One peculiar circumstance of mine is that I am running my TigerVNC server with ~/.vnc/xstartup with these contents:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/usr/bin/startxfce4 &

instead of ~/.vnc/config with something like:

session=xfce

Please see this post for why I ended up doing that: Movies are see-through in VNC

I don’t insist on specifying geometry through a .service file. I would be happy to

  • enter geometry into xstartup or
  • feed it through a systemctl start command.

Indeed the last would be most convenient as I could set geometry per session. Thanks.

ADDED LATER

A default VNC session (i.e. off /usr/lib/systemd/system/vncserver@.service) gives me 1024x768. I don’t know where that comes from (certainly not in vncserver@.service).

Once I am in, I can use this workaround:

  1. Run xrandr to find out supported resolutions
  2. Run xrandr -s 1280x960 where 1280x960 is one of the supported.

On 2, the session disconnects and reconnects at the new resolution (I would think this reconnecting depends on the viewer you use).

ADDED STILL LATER

I found out that whatever I put for geometry in ~/.vnc/config turns up in the output of xrandr as one of the supported screen resolutions, indeed the top one. (This is from when I had both ~/.vnc/config and ~/.vnc/xstartup, which turned out to be a bad idea. See below.)

So the resolution you specify there is in a tortuous way the resolution you get if you are willing, after getting to VNC, to run a xrandr -s command.

But here’s a funny thing. I tried these resolutions: 1300x900, 1300x960, 1300x970, 1300x980, 1300x988, and 1300x990.

They all work except for the 988. With this one, VNC access will fail. Isn’t that wonderful? The computer doesn’t like the number.

ADDING FOR THE LAST TIME

If you had the see-through video problem and tried adding xstartup per my other post (as linked), do NOT also use config. That will bring back the problem.

Should have the dimensions in it, ex:

geometry=1300x900

If that doesnt work … maybe because you are running system systemd units instead of user ones …

Try placing options in /etc/tigervnc/vncserver-config-mandatory

PS… as a matter of security you should probably have the server option localhost somewhere.

Thank you for the ideas, but neither of those worked.

I should note that my ~/.vnc/config used to have the very line you suggest, and it worked (gave me the geometry) until the introduction of ~/.vnc/xstartup.

Apart from getting what I want, I wonder whether

ExecStart=/usr/bin/vncsession-start -geometry 1300x900 %i

is grammatically correct (all the examples I found had it so). If it is grammatically correct but nevertheless causes an error in the “right” context, that would be interesting.

Thanks for the reminder. That will be another question, another day, from me.

It blocks all access whether over SSH or not.

As is, the server machine is confined to LAN (the house with no one but family). But still want to find out why the thing does not work, one day.

Targeting the console - screen :0 is possible but will create other issues.

I believe we have been around these topic several times.

Never use screen :0.

As Plasma based systems starts the greeter on screen :1 and the session on screen :2 these may create issues as well - at least my testing has shown those unstable an error prone.

The only method I have been able to make functional with no errors down the road is [root tip] [How To] TigerVNC Quick Setup which I created about a month ago due to the members having issues with screen :0

Always set the geometry in the user account’s configuration - whether this is /root or /home/username - as @cscs point you to.

From x0vncserver(1) — Arch manual pages (Parameter names are case-insensitive according to x0vncserver -h)

-Geometry geometry
This option specifies the screen area that will be shown to VNC clients. The format is widthxheight+xoffset+yoffset** , where +' signs can be replaced with -’ signs to specify offsets from the right and/or from the bottom of the screen. Offsets are optional, +0+0 is assumed by default (top left corner). If the argument is empty, full screen is shown to VNC clients (this is the default).

I saw this reply of yours on my other post:

I believe it was actually meant for this post.

Thanks for the idea, but it too did not have any effect. My session was at 1024x768,