woys.org:~/articles/Setting up a shared VNC session/$

  • Posted by:borbyu
  • last updated:  2008-09-27 13:59:34

Premise

My wife and I have a small apartment in the city and one of the advantages is that one sound system can provide for most of our home. Nearly all of our music is played through our computers, whether it be mp3s, internet radio, pandora, etc., so naturally it is imperative for our music playing sound system to be connected to a computer. Unfortunately we are usually on different computers and have had issues of inconvenience, not to mention long stereo cables draped across the room :(

My solution is to set up a vnc server on the main desktop which the speakers are connected to and which shares access to a desktop running on that server so that anyone on the local network may pop it up and control the music.

Requirements

  • linux server with vnc server installed. (I have a debian sid server with the debian package vnc4server installed)
  • client computer/device with a VNC viewing application installed (I use the debian package xvnc4viewer).
  • an X server installed on the server, i.e., Xorg.

Steps

1. Setup Enviroment

On the computer running the VNC server, I also use the computer as a workstation. It made it easier for me to create a new user that will run the server and therefore own the X environment that is spawned inside it. By doing this all the processes run (i.e. firefox/xmms/etc.) will be owned by that user and not conflict with what my normal user is doing.

Create unique user (I named it 'music')

root@yourserver$ adduser music

Log in as the newly created user

root@yourserver$ su music

2. Setup the VNC Server

Start the VNC server

music@yourserver$ vnc4server -geometry 950x700 -alwaysshared 
-name music -depth 16

The -geometry parameter sets the size of the desktop. I've chosen this particular size so it shows up well in the particular clients I use but you can use whatever you like. For some, the footprint of the X server may be an issue and for those you may want a smaller resolution.

The -alwayshared option is very important as it allows multiple VNC viewer applications to share the desktop and even use simultaneously... which was kind of the whole point :)

The -depth parameter is another footprint issue. I find that 16 is sufficient for my needs but if you want higher depth color you may want to go with 32.

If all goes well you should see something like this below

music@yourserver$ vnc4server -geometry 950x700 -alwaysshared 
-name music -depth 16

New 'music' desktop is yourserver:1

Starting applications specified in /home/music/.vnc/xstartup
Log file is /home/music/.vnc/yourserver:1.log

The important part of that to remember is the number after the colon. This is the desktop number that your X server has assigned this particular session.

You can optionally also edit the .vnc/xstartup file to start up applications automatically shell script style.

The first time you start the server it will ask you to set a password. This will be used to connect to the server from the client side. If you need to reset the password, kill the server and delete the .vnc/passwd file.

To kill the server run the following command, using the same number that was assigned when you started the server.

music@yourserver$vnc4server kill:1

3. Setup the client application

There are VNC clients available for most platforms, and pretty much anyone will do the trick. Most of my machines are Linux based so I use the debian package xvncviewer.

user@yourserver$ xvncviewer yourserver:1
Performing standard VNC authentication
Password:
Authentication successful
Desktop Name "music"

Again the important part of that command is that you need to know the host:(desktop #). This is the same number as was assigned when you started the server. Pretty much any VNC client will ask for a host and you will want to put that format in the prompt.

Conclusions

Advantages

I can now connect to the music server from anywhere I have access to my network, and control the music being played.

I can also have a lot of fun vying simultaneously over the music choices with others in my apartment.

Disadvantages

It does use the speakers of the computer it is connected to and since that computer also happens to be my main desktop... I obviously cannot use any sound applications at the same time.

It can only access the music library that is on and/or connected to the server, which at times is annoying if you want to play something you have on your laptop or other device.

Powered by WoysCMS. Check it out at http://woyscms.org