Version 1 of Clipboard teleportation

Updated 2004-07-23 19:45:17

July 23, 2004

I am fortunate to have two computers to use at work: a Linux desktop machine and a lightweight Windows laptop. I use the Linux machine to write and run programs, and the laptop for email, web browsing, writing documents, and working remotely from home. During the workday, they sit next to each other on my desk, and I switch back and forth between them frequently. The only problem with this arrangement is that I often will get an email message or view a web page containing commands to be executed on the Linux command line; or, I will have some program output text on the Linux machine that I want to send to someone in an email message. In that case, the half-meter distance between the two machines on my desk stands in the way of a simple cut-and-paste.

To get around this problem, I invested half a day in writing a pair of Tcl scripts which let me easily copy the contents of the Windows clipboard to the X (PRIMARY) selection on the Linux machine, and vice versa. I call this client-server system teleclip.

  • The server script, called teleclip, runs on the Linux machine as a background wish process. It has a hidden (withdrawn) window with a text widget which holds any text sent to it by the client. The text is selected as soon as it is received, so that it can be pasted into any other window with a simple click of the middle mouse button. Selecting text in any window on the Linux machine immediately makes it available for the client to receive upon request.
  • The client script, called teleclip_client.tcl, runs under wish on the Windows machine. (For convenient startup, I put a shortcut to it in the 'Quick Launch' area of my Windows taskbar.) It creates a little window with 'Send' and 'Receive' buttons. To send some text, I select it, Copy it to the Windows clipboard, and then click on the 'Send' button. To get whatever text is selected on the Linux machine, I click on the 'Receive' button and then Paste it where I want it.

This system works well for me as long as the selected text is not too long; I have had some trouble with selections longer than a few thousand characters (?), which is presumably related to the way the selection mechanism divides larger amounts of data into chunks, but I have not bothered to track this down. Note that there is no security in this system other than the obscurity of the server host name and port number (which I have changed in the scripts below to protect the innocent) and the fact that the server ignores input which does not match its very limited syntax.

(Under construction...)

Peter Shawhan