Summary:
A hardware KVM allows for the utilization of one
keyboard/mouse with many independent computers. Generally the user is
expected to turn a dial or flip a switch in order to transfer input
from one machine to another. These instructions show how to set it up
such that one can use a single keyboard/mouse combination seamlessly
between computers, without the flipping of a switch, given a few key
pieces of software and network availability.
This is specifically targeted towards users of a Linux workstation + a
Windows laptop, where the laptop is pulling a dynamic IP from a
wireless network. However, these instructions apply to many other
similar setups with little to no modification. The targeted scenario
is common enough in CS graduate lab/office environments (at
the very least) that this document seems to be worth writing.
Step 1: VNC Server
Talk:
VNC is kind of like X, but where state is preserved on the server.
That is, clients connect, are allowed to view/modify the state of a
workspace, but if the connection is somehow dropped (either
purposefully or otherwise) the client can always reconnect and find
the state unchanged due to the disruption. This is a useful paradigm
to work in for those (like me) that rarely close applications, but
tend to be physically mobile in the sense of working in many different
areas with a laptop (ahhhh wireless).
So, with VNC you can run things like an emacs session, a browser with
a number of tabs open, and a few multi-day experiments, all on a
server (such as your Linux workstation). Then, as a client, you can
connect to this workspace from elsewhere whenever you wish, for
however long you want, and never again have to worry about needing to
get all of everything re-setup each time you begin a new
session.
All of this is only tangentially related to this How-to, as in this case
we are not really using VNC in its "default" manner.
Action:
What you want to do is install a VNC server on your laptop and start
it up. Be sure to include a decent password for authentication when
you do so. There are multiple flavors of VNC implementations (it is
an open spec), of which I have linked to two at the bottom of the
page.
Step 2: x2vnc
Talk:
Now, this part is pretty cool, and is the basis of our whole
enterprise. Fredrik Hubinette, whom I have never met or interacted
with in any way, has hacked together a neat VNC client with an
important property. Namely, it is only one pixel wide.
Why is this important?
Well, it means that if you move your mouse to one side of the screen
or the other (depending on where you have the client oriented), then
as you come in contact with whichever screen edge, this client will
grab your mouse and keyboard input and begin transmitting it to the
server as any normal client should. However, while it is only one
pixel wide, it is smart enough to realize the dimensions of the remote
workspace, and only allows the mouse to escape from its control if you
move it to the appropriate screen edge, server-side. The resultant
effect is that if you have a laptop running next to a workstation,
with the edges configured according to the physical placement of the
devices, then you can watch your mouse pointer move from one screen to
the other and back again, just like a dual display setup.
Hurray!
Action:
Grab x2vnc from my included links, install it. You should be able to
connect to your laptop's server by typing in an IP address and your
cleverly manufactured password. Doesn't work? Read the appropriate
help doc (not on my pages) and figure it out.
Functionally this is as far as you need to go for the basic idea. The
rest are candy items to make the whole thing especially sweet.
Step 3: Dynamic DNS
Talk:
Now that we've setup the basic machinery, there are a couple of things
to make this nicer. x2vnc allows one to enter either a raw IP address
(123.456.789.000), or some string to be resolved via DNS lookup
("mylaptop.iamageek.org"). For laptops getting a dynamic IP over a
wireless source, one needs to lookup your current IP each and every
time you want to run x2vnc (hence the dynamic bit). Of course, many setups tend to be stale and constantly feed you the same address over and over, but that just makes it even more annoying when it actually does change.
Solution? Setup your laptop to dynamically tell a third-party its
current IP, and have that third-party resolve some hostname in your
honor. There are a number of ways to go about this, many involving
geekery. I myself simply installed a client from NoIP that offers
free and easy dynamic DNS services. I recommend the same for you, but
do whatever you like. NoIP is linked below. The only issue I ever
have with this is the need to sometimes manually run the client when I
bring a machine out of the various standby modes in Windows. But
then, for any others that might experience this same problem, you
already know that plenty of other fun geek things hate standby also,
so this is just par for the course really.
Action:
Setup some sort of dynamic DNS service for your laptop. I recommend
NoIP, which is linked to below.
Step 4: Minor scripting
Talk:
As we're all about laziness (ahem! *efficiency*) here, our setup at
this point is begging for a small little script to bring everything
together. This will get us to the point where each time you turn your
laptop on, you will either hit a single button, or run a one-line
script that sets everything up in a single go. Even better would be
if the laptop informed the workstation of its local presence, thus
saving us from even needing to do this. However, I'm not really into
the workings of geo-spatial referencing via wireless signals, and
bluetooth (though I love it) is generally not found on standard
department purchased hardware. Any ideas on this point are
welcome.
Action:
The following is a one line call to x2vnc that includes the name of your laptop, as well as a password file that you will have to create:
`x2vnc mylaptop.imageek.org:0 -passwdfile /somepath/someuser/.vnc/mylaptop.passwd`
I recommend either aliasing this, putting it in some script in a personal bin directory, or creating a Gnome/KDE launch button with this set as the command.