Karabiner
Karabiner copied to clipboard
[Feature Request] Strengthen cooperation with Synergy
Add an option that KeyRemap4MacBook stops modifying key events when Synergy is running on Mac OS X and the cursor goes to another machine.
This would be fantastic!! I have been trying to get around this my self.
@tekezo, obviously this isn't possible if you are using Synergy to access a different OS, but if the other end is also OS X, try checking out Teleport. I use that regularly and I've never noticed any weird problems with the mappings (but I don't have very many advanced ones enabled).
Thanks for the information. As you say, it is not possible unless we modify Synergy. However, there are some Synergy support requests. I'll challenge to this issue in the future.
I'm running into this too. I have my Mac as a synergy server, with a Linux box as a synergy client. I want to have remapping take place on the Mac only, but I want to be able to create exclusions so that remapping does not occur when I move over to the Linux box via synergy.
I tried to create an appdef for synergy, but that didn't seem to have any affect. Has anyone figured out how to get this to work?
Another thing is when using a windows as the synergy server, the key mapping defined in karabiner is not effective in the client on a mac book.
@paulhybryant Karabiner modifies input events in the keyboard driver. Therefore, unfortunately, Karabiner requires connected keyboards.
I have made a profile, default and inactive to resolve this issue. Would be nice to allow automatic profile switching based on an external trigger. Looks like Synergy does have a plugin model to support events.
Looks like Synergy does have a plugin model to support events.
It's great! You can use command line interface to switch profile. (select_by_name) https://pqrs.org/osx/karabiner/document.html.en#commandlineinterface
@mooreaa can you elaborate on what you mean by making a profile?
Karabiner allows you to set up different profiles which you can select from the menubar. If you go into Karabiner settings, click on the MenuBar tab, you can add a new SettingList.
I have my default profile with all the settings I like, an an Inactive setting where I have disabled all the functions of Karabiner. When I switch monitors, I switch profiles which essentially set Karabiner to a disabled state so it doesn't interfere.
It would be nice to automatically trigger this profile change when screens change. Unfortunately, the plugin model seems to only be supported on a very old version of Synergy and from Windows only.
I don't know how to detect screens change. I think that the easiest way is adding a hook into Synergy that executes shell commands when screens change.
Perhaps https://github.com/nbolton from Synergy project may be able to create some global message you can listen out for when it switches between Windows so Karabiner can toggle it's features on/off ?
Yes. If Synergy runs a shell command when OS is switched, we can use command line interface. https://pqrs.org/osx/karabiner/document.html.en#commandlineinterface
Actually, I think it would be more appropriate if Synergy provided a SDK of some sort so other programs can listen in for to know when screens have been switched.
Karabiner would be able to toggle whenever the event occurs.
There is a workaround that writes a script to tail synergy log , then we can switch profile automatically using Karabiner CLI command according to the tail result ("INFO: entering screen" , "INFO: leaving screen").
in case anyone else wants to do this via a script, this will work. replace to where you have your synergy log pointed to.
tail -f /usr/local/var/log/synergy.log | awk '/leaving screen/{system("/Applications/Karabiner.app/Contents/Library/bin/karabiner select 0")} /entering screen/ {system("/Applications/Karabiner.app/Contents/Library/bin/karabiner select 1")}' &
OK, so my config is a Mac and a Windows PC. The Mac is the Karabiner 'Server' and the PC is the client. On the Mac I've set up two profiles. Default Profile is the one on which I've enabled the settings I want for the Mac and the second profile ("PCMode") has settings for when I've moved the mouse into the PC screen area.
All is great now and I've got my keyboards working really well with the Synergy and Karabiner combo. I used the example tail command above (thank you plessbd!) but tweaking it by swapping around the "select 0" and "select 1".
@tekezo Hi! I am using Synergy with a Windows machine as server and my Mac as client. You mentioned, that Karabiner modifies input events in the keyboard driver and therefore requires connected keyboards.
But, when I open the Karabiner Event Viewer, I actually see the events from synergy
CTRL + C from Mac: eventType:FlagsChanged code:0x3b name:left_control flags:Ctrl eventType:KeyDown code:0x8 name:c flags:Ctrl eventType:KeyUp code:0x8 name:c flags:Ctrl eventType:FlagsChanged code:0x3b name:left_control flags:
CTRL + C from Synergy: eventType:KeyDown code:0x8 name:c flags:Cmd eventType:KeyUp code:0x8 name:c flags:Cmd
As you can see, the events from Synergy do not contain the "FlagsChanged" events, though in the KeyDown/KeyUp events the flags are correclty set. Shouldn't this information be enough to modify the events??
Now that karabiner is obsolete and I've switched to Karabiner-Elements, here's my workaround for Synergy if anybody happens to stumble onto this thread. Working on top of @plessbd idea.
Get JQ - quick 1 minute download Create shell script: I named it switch_karabiner.sh
#!/bin/bash
PROFILE=$1
JQ="${HOME}/bin/jq"
CONFIG=".config/karabiner/karabiner.json"
TMP_CONFIG=${CONFIG}.1
${JQ} ".profiles[].selected = false" ${CONFIG} \
| ${JQ} ".profiles[${PROFILE}].selected = true" \
> ${TMP_CONFIG}
if [ $? != 0 ]; then
echo "Failed!"
rm ${TMP_CONFIG}
else
mv ${TMP_CONFIG} ${CONFIG}
fi
Change variables as needed. My setup is 0 - Mac, 1 - Linux
Then you just call that script with @plessbd script:
tail -f /var/log/synergy.log | awk '/leaving screen/{system("~/bin/switch_karabiner.sh 1")} /entering screen/ {system("~/bin/switch_karabiner.sh 0")}' &
PROFIT!
Karabiner Elements now supports switching profiles via CLI, e.g. '/Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_cli' --select-profile '-'
. I have problems trying to implement this workaround on the Synergy 1 side though:
- I don't have /var/log/synergy.log: running Synergy GUI.
- When I try to switch to
synergys
CLI, I getFATAL: A runtime error occurred: assistive devices does not trust this process, allow it in system settings.
. I was able to overcome it when running synergys from iTerm2 by adding iTerm to the Accessibility whitelist. However, I run Synergy server on startup via custom shell script lunched from a user agent, and I'm out of luck because the Accessibility whitelist accepts only apps.
I reported these to Synergy support. I'll see what they say.
It's 2020 and I'm using Barrier instead of Synergy, and here's how I integrate it with Karabiner-Elements using Hammerspoon: https://gist.github.com/knu/8b3b784100bae2f8088ff09afc7c451b
It's 2020 and I'm using Barrier instead of Synergy, and here's how I integrate it with Karabiner-Elements using Hammerspoon: https://gist.github.com/knu/8b3b784100bae2f8088ff09afc7c451b
This was amazing. Thank you!