There are a few different ways to get this done as you might imagine, but this is probably the most appropriate. There's a shell script named xstartup
created when you run vncpasswd
the first time for a user. This file can be modified to run arbitrary code. When modifying and testing changes, set up debug logging and tail the relevant logfiles to troubleshoot the changes.
Several VNC-related files are found in the directory $HOME/.vnc. Among them:
$HOME/.vnc/xstartup
A shell script specifying X applications to be run when a VNC
desktop is started. If it doesn’t exist, vncserver will create
a new one which runs a couple of basic applications.
Often, setup will place logic in ~/.vnc/xstartup
and you'll need to use discretion to insert the line to be run when a session is initiated. Try starting something simple but good at producing error messages at first, like
xterm -geometry 40x24+10+10 -ls -title "$VNCDESKTOP Desktop"
For best results insert that line before or after the line in xstartup which starts your window manager.