Originally Posted by
Woek
One has ubuntu, with four desktops. I would like to have the other computer sometimes display the contents of one of the desktops of the ubuntu machine via VNC
This isn't possible. VNC if it were configured like that would always display the same content as your Ubuntu system. You'd get 2 x screens with the same content.
Originally Posted by
Woek
Is it possible to configure a vnc server to only display the content of one of the desktops, not always the one currently visible?
Your question should be:
"... Is it possible to configure a vnc server to display the content of a different desktop environment and not the one that is visible on the main screen?"
YES. This is possible.
Example from one of my own systems:
The main desktop environment is GNOME. That's what you see when you turn the screen on. But I also have a 2nd desktop environment that is NOT visible on any screen unless you connect a VNC session to it.
For this I installed the LXDE desktop environment (can easily be found in the "Synaptic" package manager) and its tools and the "vnc4server" package.
Once the packages are installed you need to execute this command:
vncpasswd
Please choose a good and hard-to-guess password with letters, numbers, extra signs, and so on.
I then edited the file /etc/rc.local (needs to be done as root, so you'd use e.g. "gksu gedit /etc/rc.local" to do that) and added these lines at the bottom but before the last 2 x lines:
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# Launch VNC session for sysadm
/bin/su - sysadm -c "/usr/bin/vnc4server :1 -depth 16 -geometry 1200x768"
# By default this script does nothing.
exit 0
What that line does:
It launches a virtual VNC desktop session on a second, non-existing virtual screen ":1" (your real screen with e.g. GNOME is ":0" in Linux lingo ... but that's not the one we want) under the user "sysadm" and it sets that virtual screen to a fancy screen resolution of 1200 x 768 pixels (yeap, you can make up what you want, that screen resolution doesn't neet to correspond to real screen resolutions!).
To make really really sure we really get LXDE desktop environment when VNC gets auto-launched you need to edit a few more files.
After executing "vncpasswd" above there should now be a ".vnc" directory in your home. In there there should be a file called "xstartup". This file controls which programs and desktop environments the standalone VNC server will start. So we need to edit that one.
My file looks like this ( ~/.vnc/xstartup):
Code:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -nowin &
/opt/teamviewer/teamviewer/6/bin/teamviewer &
lxterminal &
transmission &
lxsession &
What happens here is that when VNC auto-launches I first define that the screen background color should be grey, that a little VNC helper tool should be launched (it enables copy & paste of text between connected systems), that teamviewer, a terminal emulator and my favourite BitTorrent program should be launched, and that I want it all managed by the LXDE session. The ampersand "&" after each line makes sure that the programs are executed in the background and that the script continues regardless whether or not the programs that were launched are finished executing or not (without the "&" the script would get stuck after each line and wait for the programs to finish before triggering the next program on the following line ... )
Sorry for the long text but it's really easy. With above trick I can use my normal GNOME desktop and plus I can use the VNC connection as additional desktop. And if I lock the physical screen it doesn't affect the programs that I launched in my VNC session, they will continue to work regardless whether I am connected or not.
So yes, this is a good way to leave programs running in the background without leaving your physical screen unlocked.
However: please be aware that VNC is very very *INSECURE* as protocol. Do not open your firewall/router for VNC access to the outside world, only use this within your own LAN, OK? For secure remote access there are better solutions than VNC. I for example use Teamviewer (www.teamviewer.com) for this.
Hope this helped?
Bookmarks