Karabiner-elements: Detecting changes in karabiner.json not working when symlinked

Created on 30 Jan 2017  路  9Comments  路  Source: pqrs-org/Karabiner-Elements

I have a symlinked setup like this:

$ cd ~/.config/karabiner/
$ ls -l
total 4
lrwxrwxr-x 1 plundberg staff 54 Jan  2 08:55 karabiner.json -> /Users/plundberg/git/dotfiles/karabiner/karabiner.json

The purpose of this is to be able to keep my dotfiles under git version control.

This used to work fine, _but_ when Karabiner Elements moved its configuration file to ~/.config/karabiner/karabiner.json from its previous location (cannot remember what it was), Karabiner Elements stopped detecting changes to this file:

  • When making a change in the file, it is no longer automatically detected.
  • When switching profiles in Karabiner Elements, it doesn't take effect - I have to quit the program and start it up again for the change to come into effect.

Was there any change made in the listening of file system events at the same time as the config was moved that could have triggered this?

Most helpful comment

Use symlink with ~/.config/karabiner instead of karabiner.json.

$ ls -l ~/.config/karabiner 
lrwxr-xr-x  1 tekezo  staff  39 Feb 28 00:52 /Users/tekezo/.config/karabiner@ -> /Users/tekezo/Dropbox/private/karabiner

Note:
You have to restart Karabiner-Elements after you changed the realpath of ~/.config/karabiner.

All 9 comments

I am hitting this as well. @perlun have you found any workarounds?

FWIW, I dropped the symlink, made my setup script copy the file and profile switches now take effect without restarting karabiner-elements.

I am hitting this as well. @perlun have you found any workarounds?

Nope. What I tend to do: switching the profile, quitting Karabiner, restarting it again. It's annoying but it's the best I have at the moment.

Definitely don't want to drop the symlink in my case, since I have the file in a git repo.

Use symlink with ~/.config/karabiner instead of karabiner.json.

$ ls -l ~/.config/karabiner 
lrwxr-xr-x  1 tekezo  staff  39 Feb 28 00:52 /Users/tekezo/.config/karabiner@ -> /Users/tekezo/Dropbox/private/karabiner

Note:
You have to restart Karabiner-Elements after you changed the realpath of ~/.config/karabiner.

Thanks for hint, this trick indeed works!

Thanks @tekezo, will try that! I guess it's not easily possible to fix it while letting the actual _file_ be a symlink? (I think it used to work in the old KeyRemap4Macbook a.k.a. Karabiner non-Elements version)

It's a limitation of macOS API.
Karabiner-Elements uses File System Events API to detect the file update.
The API observes the parent directory state (~/.config/karabiner).

But when using the actual file symlink, karabiner.json updates /Users/plundberg/git/dotfiles/karabiner state.
That's why Karabiner-Elements is missing your karabiner.json changes.

That's why Karabiner-Elements is missing your karabiner.json changes.

Understand, thanks for the explanation. But I have the feeling that the file symlink worked with KeyRemap4MacBook. OTOH: I'm not 100% sure about that, it _could_ be that I used to have a directory symlink but set up a file symlink now incorrectly...

Anyhow, thanks for clearing this out and documenting the workaround here. 馃憤

Was this page helpful?
0 / 5 - 0 ratings