Synergy: Cannot send media keys from Linux to Mac

synergy

I have a Linux Synergy server (Si-Linux) serving just one Mac client (Macbook Pro UK) (SiBook-Pro.local).

On my Linux server I am using a USB Apple keyboard with the exact layout of the laptops keyboard (the compact UK aluminium keyboard).

I would like to send the media keys to the Mac client at all times and I have attempted the following in my synergy.conf:

keystroke(AudioPlay) = keystroke(AudioPlay,SiBook-Pro.local)

This did not seem to work so I ran both the server and client as foreground processes and with debugging enabled and observed the following:

Server Log:

DEBUG1: activate actions
DEBUG1: hotkey: keyDown(AudioPlay,SiBook-Pro.local)
DEBUG1: onKeyDown id=57523 mask=0x0000 button=0x0000
DEBUG1: send key down to "SiBook-Pro.local" id=57523, mask=0x0000, button=0x0000
DEBUG1: deactivate actions
DEBUG1: hotkey: keyUp(AudioPlay,SiBook-Pro.local)
DEBUG1: onKeyUp id=57523 mask=0x0000 button=0x0000
DEBUG1: send key up to "SiBook-Pro.local" id=57523, mask=0x0000, button=0x0000

Client Log:

DEBUG1: recv key down id=0x0000e0b3, mask=0x0000, button=0x0000
DEBUG1: mapKey e0b3 (57523) with mask 0000, start state: 0000
DEBUG1: key e0b3 is not on keyboard
DEBUG1: recv key up id=0x0000e0b3, mask=0x0000, button=0x0000
DEBUG1: recv enter, 1279,386 5 2000

As you can see, the client claims the key received is not on keyboard. I don't understand since it is the same key as is on the Macbook's keyboard.

I tried to reverse the client-server config to see if I could capture the key being sent if I pressed the Play button on the Macbook but the key doesn't seem to even make it to Synergy. Almost all keyboard presses get logged but the media keys seem to bypass the logs and just execute their function locally. E.g. I press play on the Macbook (with the Macbook as the server) and the key plays music on the Macbook and the key is not logged to the debug log.

Best Answer

This is a limitation in the Mac Synergy Client. There are two things preventing Mac Synergy from handling multimedia keys:

  1. Mac Synergy builds it's keyboard map from the Mac keyboard layout (e.g. American English, French, etc.) and these don't contain media keys
  2. The Mac API doesn't allow you to generate synthetic key presses that correspond to pressing multimedia keys.

I've written a patch to Mac Synergy (and submitted it to the project at http://synergy-foss.org/spit/issues/details/3375/ ) that works around both of these problems, by inserting media keys into the layout manually, and by using serialized media key presses recorded during an actual key press.

You can download the patch yourself and compile synergy, or add a note to the issue requesting it be integrated. If neither of those work, contact me, and I can send you the binary I'm using...

Related Question