A thing that has been driving me up the wall about my synergy setup at work is this. The main server is the Windows laptop that I use, which is fine when it’s docked, and when it’s mobile the server is disconnected from the clients (counter-intuitive I know but bear with me). The server only runs on the wired ethernet so the client doesn’t pick it up over wireless.
All well and good, when docked I have Windows dual screen with Ubuntu joy over on the the third screen.
Now, the only small problem is everything is on DHCP… and every so often the addresses change. Which is annoying. It means reconfiguration by hand on the Ubuntu box, after first running ipconfig on the windows box (by the way, anyone want to point me at an app that pops up the IP address in a tooltip over the network icon on the tray ? Make this a whole lot easier…).
The solution ? Automate (finally). Involving the magic of nmblookup (DHCP client on the laptop does not register itself as a DNS entry, so you find the server via WINS, which Ubuntu needs help with).
The script (see the cut) attempts to figure out if the synergy client is running or if it has died, if it has died, it attempts to restart, after first finding the server. The client should die when the connection is killed (simulate this by clicking on the “Force Reconnection” option in the Windows Synergy server context menu). So essentially, undock the laptop, and the connection is killed. If the laptop is switched off or not connected, the ip address is not available and the script with try again later. The Script itself is run via crontab. The ip address is extracted from nmblookup by using gawk (see after cut).
If there are two IP addresses for the same box, the behaviour is a little undefined, you’d need to modify the gawk script to fix this.