2009/06/05

Fixin' what ain’t broken

or : how to use synergy and a broken eeepc to get almost decent mouse performances on a mac.

Initial setup

I have a Happy Hacking Keyboard (lite 2) keyboard, which is a very nice japanese keyboard made by PFU/fujitsu. I bought it to use it at work with my linux machine, to replace a kilometer-long keyboard. I am on a two weeks holiday, so I decided to bring it home, and to try to use it with my Macbook Air.

A friend of mine gave me his broken eeepc a while ago. The screen is toast, but the rest works nice. It is slow but has more expansion ports than my Macbook Air ;-) The machine is still running he original linux offspring that came with it, a fork of debian called xandros with some asus modifications. A strange mix.

At work, I sometime bring my laptop and connect my workstation and my laptop using synergy. It works very well, and the mouse moves at the normal speed, not at the sluggish speed that mac os x believe it should. At home, I almost never use the external mouse, keyboard and screen. But for the holidays I wanted to try again. Of course, the simplest solution to make everything work smoothly is to use USB Overdrive. It can make USB mice behave in a more usual fashion. You just have to buy it for 20 USD. And plug and unplug everything everytime you want to use the setup.

I tested both the synergy and the USB overdrive method, and the overdrive way works better, as there isn’t 3 networks for the information to travel through. For the synergy method, there is always an almost imperceptible delay when you start a movement, but you don’t loose precision as the pointer “teleports” where it should be. The cursor sometimes moves choppily.

0 - How to edit files on the eeepc

To edit files you need to see them. You could use the file browser, but I prefer to use the command line. You can open a command line using two methods.

  • a simple “Ctrl-Alt-t”
  • in the work tab, launch the “File Manager”, select the “Tools” menu, then the “open console windows” option.

As you need to be root to edit most of the interesting configuration files, you have to prefix the launch of the editor with the sudo command, which allow a user to do something as if he was root. For example, if you don’t know the password of the user but need to set it, the following command allows you to set the password :

sudo passwd user

It will work on the eeepc because the sudo command doesn’t ask you for your password as it would on my linux workstation.

For the editor, I use kate, which is a nice not too slow to launch editor.

1 - How to install synergy on a vanilla eeepc 900

The synergy package is not installed by default, and isn’t part of the default eeepc repository. You have to install it from a Debian repository. Here’s how.

To add a debian repository. In a console execute the following command :

sudo kate /etc/apt/sources.list

Add the following line at the end of the file, save, quit kate :

deb http://http.us.debian.org/debian/ etch main contrib non-free

Launch synaptic from the console :

sudo synaptic

Click on the search button and search for “synergy”, select it, and click on the apply button.

You now have synergy on your eeepc.

Here is what i tried but didn’t work :

  • Installing the package from source : doesn’t work because the gcc package is not installed, and trying to install gcc finds some conflicting dependencies.
  • Installing the binary from the rpm package, by unpacking it : there is no rpm related command in the root or user path.
  • Installing the .deb package from the debian website : I could only get the lenny version, and it seems that the distro on the eeepc is closer to the etch version.

2 - How to configure synergy

The configuration file contains the relative position of all the screen that will be connected together. You can read the documentation at the synergy website and click on configuration (uses frames, so i can’t link to the page with both the nav bar and the content) or straight to the config page.

My own setup is barebone :

section: screens 
	Ikki: 

	asus: 
end

section: aliases 
	Ikki: 
		192.168.0.6 
		Ikki.local 
end

section: links 
	asus: 
		left = Ikki

	Ikki: 
		right = asus 
end

The synergy client is launched from from the command line, with just the address of the server : synergyc serveradress i.e. synergyc 192.168.0.5

The synergy server needs the location of the configuration file:

synergys --config synergy.conf

i.e. on the eeepc synergys --config /home/user/sillyScripts/synergyIkki.conf

3 - How to launch the synergy server at startup

Actually, as the server needs both the network interface up and the X server to be launched, it should be the last thing that is done. You also want the server to run as a the user, and not as root.

First you have to write a script that executes all you need. In the case of the happy hacking keyboard, you might want to change the keymap, then start the synergy server. Here is the script I use :

#change the keyboard layout
setxkbmap -display :0 -model jp106 -layout jp
#remap the keys left and right of space to space.
xmodmap -display :0 -e "keycode 131 = space"
xmodmap -display :0 -e "keycode 129 = space"
killall synergys
sleep 1
/usr/bin/synergys --config /home/user/sillyScripts/synergyIkki.conf
#play a sound when everything is done
mplayer /home/user/sillyScripts/cff_f.mp3

To make sure that everything is working fine, start your script from the command line. i.e.:sudo -u user bash /home/user/sillyScripts/startStuff.sh

Then add that last line the system startup script: sudo kate /usr/sbin/services.sh scroll to the end, and add your command to the last line.sudo -u user bash /home/user/sillyScripts/startStuff.sh`

And voila ! your eeepc can now export its keyboard and mouse to another machine.

Here is what I tried but didn’t work :

  • Adding the startStuff script to the /etc/rc.local file. This file is not used by the system apparently.
  • Adding the startStuff script to the /etc/fastservices file. The script seemd not to be run either.
  • Running the startStuff without sudo. I don’t know why, but it didn’t work either, thus sudo -u user prefix to the bash command.

5 - Bonus: using ssh tunneling for fun and privacy.

As my connection is using the airwaves and I’d like to keep my blog posts private until I publish them, I added ssh tunneling to the setup. Here’s how you can do it too.

On the server, you have to start the ssh daemon : open a console, sudo kate /usr/sbin/services.sh Scroll to the end, and just before you start your script add sshd

This will launch the ssh server. You will then have to create an ssh tunnel to the server on you client machine. This machine needs to have the ssh client installed.
To create the tunnel : ssh -f -l user -N -L 24800:192.168.0.5:24800 192.168.0.5 Then to connect to the server through the tunnel : synergyc -f localhost

The command redirects your local port 24800 to the remote machine 192.168.0.5 on its port 24800. the second 192.168.0.5 means that tis is the machine through which the port will be forwarded( it could be any other machine on the same wired network as the destination machine). Every time you will want to securely connect to the synergy server, you will have to start this script first. then,

Afterword:

I understand the exporting your eeepc mouse and keyboard is not the most practical thing to do. It can however be of use when you want to remotely control a HTPC and are too cheap to buy a remote keyboard.

 
Archives / RSS
— ~ —