Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

[Feature Request] Strengthen cooperation with Synergy #15

Open
tekezo opened this issue May 12, 2011 · 22 comments
Open

[Feature Request] Strengthen cooperation with Synergy #15

tekezo opened this issue May 12, 2011 · 22 comments

Comments

@tekezo
Copy link
Member

tekezo commented May 12, 2011

Add an option that KeyRemap4MacBook stops modifying key events
when Synergy is running on Mac OS X and the cursor goes to another machine.

@pellesg
Copy link

pellesg commented Jun 16, 2011

This would be fantastic!! I have been trying to get around this my self.

@bjeanes
Copy link

bjeanes commented Dec 1, 2011

@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).

@tekezo tekezo closed this as completed Dec 2, 2011
@tekezo
Copy link
Member Author

tekezo commented Dec 2, 2011

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.

@tekezo tekezo reopened this Dec 2, 2011
@loudsong
Copy link

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?

@paulhybryant
Copy link
Contributor

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.

@tekezo
Copy link
Member Author

tekezo commented Sep 21, 2014

@paulhybryant Karabiner modifies input events in the keyboard driver.
Therefore, unfortunately, Karabiner requires connected keyboards.

@mooreaa
Copy link

mooreaa commented Feb 26, 2015

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.

@tekezo
Copy link
Member Author

tekezo commented Feb 26, 2015

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

@paulhybryant
Copy link
Contributor

@mooreaa can you elaborate on what you mean by making a profile?

@mooreaa
Copy link

mooreaa commented Feb 28, 2015

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.

@tekezo
Copy link
Member Author

tekezo commented Mar 10, 2015

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.

@twig
Copy link

twig commented Jul 3, 2015

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 ?

@tekezo
Copy link
Member Author

tekezo commented Jul 3, 2015

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

@twig
Copy link

twig commented Jul 4, 2015

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.

@petersonchen
Copy link

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").

@plessbd
Copy link

plessbd commented Oct 8, 2015

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")}' &

@aminor00
Copy link

aminor00 commented Oct 19, 2016

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".

@ndreisg
Copy link

ndreisg commented Oct 19, 2017

@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??

@kranasian
Copy link

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!

@DKroot
Copy link

DKroot commented Jan 6, 2019

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:

  1. I don't have /var/log/synergy.log: running Synergy GUI.
  2. When I try to switch to synergys CLI, I get FATAL: 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.

@knu
Copy link
Contributor

knu commented May 14, 2020

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

@zyrain
Copy link

zyrain commented Sep 9, 2020

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests