Breaking Code

September 8, 2010

A dual screen hack: x2vnc

Filed under: Just for fun — Tags: , , , , — Mario Vilas @ 6:30 pm

Today I just had to use two laptop computers simultaneously, and switching back and forth was driving me insane. Then I remembered an old trick I used to pull back at my old job: the dual screen hack.

Most of you probably know it already, but just in case, here goes the explanation. You can connect two computers and simulate what would happen if you had two monitors instead: when the mouse leaves the screen in one computer, it “enters” the other computer on the opposite side of the screen. For example, if you have two laptops on your table and you move the mouse to the right, after reaching the border of the screen you see it coming out on the left side of the other computer. :)

The magic is done by using a remote desktop protocol like VNC, which lets you send keystrokes and mouse events, but discarding the framebuffer updates. That is, a program that connects to the remote desktop, but instead of showing you the remote screen, it monitors mouse movements locally and when the mouse reaches the screen limits, it captures the mouse and starts sending mouse events to the remote system. Similarly, when the mouse reaches the opposite limit on the remote system, it stops capturing the mouse so you can use it on the local system.

Since I use Linux my choice was x2vnc, the Linux cousin of the more famous Win2VNC, also by the same author. But unlike Win2VNC which is now actively maintained at SourceForge, x2vnc seems to have been abandoned.

x2vnc supports SSH tunneling, which is just perfect since VNC is a plaintext-only protocol and insecure by design. However there’s no easy way to tell x2vnc to which port to connect or which username to login as – it defaults always to the current local user and port 22.

I also had a problem with my other laptop, which had Windows 7. When the mouse cursor leaves the screen, it is “parked” to a corner of the screen so it doesn’t show (it’d be confusing to see two mouse cursors as you wouldn’t know which one is active). But the corner chosen by x2vnc is always the lower right corner, causing Windows 7 to hide all active windows… very annoying.

So I did what any other geek would do in my situation – branch it! :D

The patched code is now at Google Code. The new command line switches I added were:

-sshuser: Log in to the SSH tunnel using the given username.

-sshport: Connect to the given TCP port number instead of the SSH default (22).

-restingx and -restingy: Tell x2vnc where to park the mouse cursor. A value of 0 means left or top, a value of -1 means right or bottom. Then for example, -restingx 0 -restingy -1 means the top right corner of the screen.

Currently there’s only the source code but if I have the time I’ll upload a precompiled Debian package as well. Enjoy! :)

Download

Source code: http://code.google.com/p/x2vnc/source/checkout

About these ads

11 Comments »

  1. Also, see synergy ( http://synergy-foss.org/) which is similar

    Comment by D — September 8, 2010 @ 7:54 pm

  2. http://synergy-foss.org

    Comment by D — September 8, 2010 @ 7:54 pm

  3. [...] This post was mentioned on Twitter by Mario Vilas, xanda. xanda said: A dual screen hack: x2vnc http://bit.ly/cFEMmz [...]

    Pingback by Tweets that mention A dual screen hack: x2vnc « Breaking Code -- Topsy.com — September 9, 2010 @ 2:31 pm

  4. At least as far as I know Synergy doesn’t directly support SSH tunneling, so I’d have to build the tunnel manually. :(

    I do like how they reversed the client-server relationship, though, and it’s much better to handle multiple computers…

    Comment by Mario Vilas — September 9, 2010 @ 5:01 pm

  5. Very interesting, i think it is very important to know that. Don’t hesitate to share it again, i think it is so useful to know.

    Comment by Downloadhack — October 3, 2010 @ 10:30 pm

  6. [...] under: Just for fun Tagged: Debian, LinkedIn, linux, open source, tool Breaking Code This entry was posted in Breaking Code and tagged dual, hack, screen, x2vnc. Bookmark the [...]

    Pingback by A dual screen hack: x2vnc | Linux-backtrack.com — January 23, 2011 @ 10:58 pm

  7. Realmente muy funcional, me encanto la manera en que se redacta el contenido… me sirvio de mucho, gracias.

    Comment by Golfizta — March 27, 2011 @ 9:33 pm

  8. I’ve been browsing online more than three hours today, yet I never found any interesting articles like yours. Personally, if all website owners and bloggers made excellent content like this, the internet will be a much more useful place. Well done! and keep up the good work :-)

    Comment by Sun Bingo Lobby — September 22, 2011 @ 4:08 pm

  9. no SSH support in Synergy.x2vnc supports SSH tunneling, which is just perfect since VNC is a plaintext-only protocol

    Comment by Sun Bingo Lobby — September 22, 2011 @ 4:10 pm

  10. Awesome, just what I was looking for – going to give this a go right now. many thanks

    Comment by Jackpot247 — September 22, 2011 @ 4:11 pm

  11. [...] to this post by Mario Vilas, I realized this is due to the ‘Aero Peek‘ feature. His approach was to [...]

    Pingback by jeremyslade.com :: Disable Aero Peek when using x2vnc — September 29, 2011 @ 3:59 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Silver is the New Black Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 2,479 other followers

%d bloggers like this: