The magic of x2x and x2vnc

May 10, 2006 18:41

I have solved this problem about 7 times now. And everytime I reboot the machine, all the xhost  and nolisten tcp stuff that I did to my X server will vanish. And, considering the amount of RAM I have in my head, I will start from scratch once again, wondering how to go about doing it. So, this time I decided to write it up, atleast for my convienience.

So, Without any further crap...Let us assume you have two machines ( hosts) at your workplace/home..They have two displays ( monitors) and you dont have ( or want to have) a KVM switch. Two displays at the same time is good, but two keyboards  and two mouses is a really irritating thing. I end up typing my password using the wrong keyboard all the time. Or hang on to the wrong mouse and wonder what the hell is wrong with it. I also used to wonder if there is a way to pass a piece of text ( from the clipboard) , say a URI from the browser of host A to the browser on host B. Unintelligently, I used to run a messenger client on both the hosts, and send the blob over IM back and forth.

Connecting two X servers:
Ok, Now that we are convinced we need something better here, let me introduce x2x. It is a magical pixel grab software that works really well on two different OSs. ( I connect a linux host to a FreeBSD host). Thanks to the concept of X server. You could get the sources from here or check out your ports distro for packages.

Install x2x on one of the two hosts (that has the better mouse and keyboard) and then issue a command like this:

x2x -west -resurface -to tohostname:displayport

Dissection:

-west:  This means that the host you are connecting to ( Or the host you wish to use without it's mouse/keyboard) is to the west of the host you are connecting from. If you are poor in directions ( and I always say a lot of women are), think of the number "4".. Draw the number "4" with the horizontal line first starting from the right. This is your east..and then go "east , west, north and south" as  you write "4".

-resurface: Not so important..Check up x2x -h or the man page for more info.

-to: This signifies that the following string is the host you want to connect to ( Or pixel grab from).

tohostname:displayport: This the hostname and the display port. For ex, my.host.name:0.0

How do you figure out what the display port is? go to the host you are connecting to and then type

echo $DISPLAY

That will tell you what display port you must connect to. Now that we are at it, the default X port is 6000 which is signified by 0.0 . U can also run multiple X servers on the same host listening at different ports. In that case, your display port must go 0.1 , 0.2 etc , which actually translates to port 6001. 6002 etc...

Thatz it. Put this as a rc command so that it gets fired everytime your host reboots, and that you can always use the same mouse/keyboard without having to run x2x everytime.

Important notes:

  • All X servers, by default run with the option "-nolisten tcp". What this means is, the X server is listening on a unix domain socket and that it wont listen to TCP connect requests from the network.
For instance, if you are running gdm, then a ps ax | grep gdm will show the arguments passed to gdm and one of them will be "-nolisten tcp" . You have to open up your gdm.conf (in my case, it is at /etc/X11/gdm/gdm.conf ) and then explicitly set DisallowTCP as false. Restart the X server and you will be fine.

  • You might also have to do a "xhost +from.host.name" so that the X server running in to.host.name allows the from.host.name to connect to it.

Connecting to a windows host from a host that runs X:

I also sometimes boot up windows. That shouldnt deter us from doing magic, should it?
Ok, install a VNC server on your windows host. RealVNC is a really good, free to use VNC server for windows. Start up the VNC server and then make sure you allow clients to connect ( with or without authentication) , and other stuff that it has.

Download x2vnc sources from here or check your distro for packages. your x2vnc command will be very similar to the x2x. As I am losing patience, please check "x2vnc -h" or the man page for more details.

Hope that helps someone..

x2x x2vnc xserver windows linux

Previous post Next post
Up