Saturday, October 6, 2007

Drive the N800 from a PC or Mac with VNC

The N800 stylus and virtual keyboard, while functional, are not the most convenient methods of data entry. When you have a PC or Mac on hand, a human sized keyboard and mouse are certainly preferable.

I'll give you some background in case you haven't used VNC on your PC or Mac before. VNC is actually a pair of applications: VNC server runs on the device you want to drive (the host) and VNC viewer runs on the device you want to drive with (the guest). In this case, the host is the N800 and your PC/Mac is the guest.

Installing the software
VNC is open-source and comes in a few different flavors. I've chosen RealVNC but any variation should do the trick. You can download and install the free version of RealVNC viewer here.

Next you'll need to install a VNC server on the N800. As of this writing, you can find a VNC server installation package for the N800/N770 here.

After you install VNC server, there should be a new menu item under Extras named x11vnc. There is no user-interface for this application. When you launch it, VNC server runs in the background. Launching it again unloads the VNC server.

Finding the IP Address of your N800
Connect the N800 to your WiFi network by initiating a browser session or whatever means you find easiest. On the N800 navigate to Tools > Connection Manager. At the top of the screen there is a pulldown menu where you can select Internet connection > IP address. Write the IP address down because you'll need it to connect the VNC viewer on your PC or Mac to the VNC server on the N800.

Connecting
Launch the VNC server application (x11vnc) on the N800. When you do this, it appears that nothing has happened because the program has no user interface. VNC server is silently running in the background.

Launch the VNC viewer application on your PC or Mac. It will prompt you for the server that you want to connect to. In the space provided, enter the IP address that you obtained earlier. A connection should be establish fairly quickly and you will see a window open up that looks just like whatever happens to be displayed on the N800.

Using the mouse
According to this post the mouse pointer and clicks don't work on the task launcher icons on the left edge of the screen. The author describes a somewhat dangerous workaround which involves disabling touchscreen input. However, a much simpler solution is to use the F3 keyboard shortcut and the up/down arrow keys to pop-up the task launcher menus when you need them. Once you have the menus popped-up, mouse movements and clicks seem to work just fine.

Additional keyboard shortcuts
The same default shortcuts that are setup for a bluetooth keyboard also work in the VNC client. You can see a list of these shortcuts, and even edit them if you like, by going to Tools > Control panel > Hardware keyboard > Shortcuts. Here is the default list:
  • F4: Close
  • F9: Minimise
  • F3: Task launcher
  • F9: Task switcher
  • F6: Full screen key
  • F7: Plus key
  • F8: Minus key
  • F4: Menu key
  • F5: Home view
  • F12: Power menu

Security
One important thing to consider is that the script that launches VNC server on the N800 does not set a password for the connection. So if you are on an open Wifi network, there is not really anything to prevent someone from connecting to your N800 with their own VNC viewer.

If you're comfortable with the Linux command line, you can edit the line in the script that launches VNC server to add a command line option that establishes a password for connections. The script is /usr/bin/x11vnc.sh.

To add the password option, look for the line that reads:

exec /usr/bin/x11vnc -cursor -arrow > /tmp/x11vnc.log 2>&1

And update the line so that it reads:

exec /usr/bin/x11vnc -cursor -arrow -passwd Tabl3tWiki > /tmp/x11.vnc.log 2>&1

Replacing Tabl3tWiki with whatever password you would like to use. Next time you launch the VNC server and try to login with your VNC viewer, the viewer will prompt you for a password.

Wifi Timeouts
The default behaviour of the N800 is to drop the Wifi connection after some pre-determined period of inactivity. If this happens during a VNC session you will lose your VNC client connection and the window will no longer accept inputs. The server remains loaded but it will not resume function when the Wifi connection is restored. If this happens, you'll need to run x11vnc once to unload the non-responsive server and run it a second time to reload the VNC server and get it working with the restored Wifi connection.

This work-around seems to help: edit the /usr/bin/x11vnc.sh script to add one more parameter.

Assuming you made the edits described above to add the password option, look for the line that reads:

exec /usr/bin/x11vnc -cursor -arrow -passwd Tabl3tWiki > /tmp/x11.vnc.log 2>&1

And update the line so that it reads:

exec /usr/bin/x11vnc -cursor -arrow -fixscreen V=60 -passwd Tabl3tWiki > /tmp/x11.vnc.log 2>&1

The new -fixscreen v=60 option forces a full screen refresh every 60 seconds. You can change the 60 to another number to find out what works best. Since each refresh is a waste of bandwidth and will degrade performance, it's best to set the number as high as possible to avoid doing it more often than absolutely necessary.

No comments: