How can I disable Karabiner-Elements for Emacs.app and Emacsclient.app

689 views Asked by At

I am unable to use C- key in Emacs.app or Emacsclient.app gui applications when Karabiner is enabled. C- is backbone to use Emacs all keybindings are dependent on it.

Is it possible to completely disable Karabiner-Elements only for the Emacs.app on Emacsclient.app?

My config file: https://gist.github.com/avatar-lavventura/e13216d2156984dc88b79eb0df555a56

2

There are 2 answers

13
Q.u.a.n.g L. On BEST ANSWER

I once fall into your situation but for crossover, then I found a way to disable Karabiner for the crossover app. I dont know the emac bundle id so you search for it :).

  • Open the Karabiner event viewer and find out the window information for the application you want to provide specific settings for
  • Open the Karabiner application
  • Click on the Misc & Uninstall tab
  • Click on Open private.xml
  • Open the private.xml file in your text editor
  • The References at the top of the article describe how to get a configuration that works for a specific app

After creating and saving your private.xml, go back to the Karabiner application

  • Click on the Change Key tab
  • Click on the Reload XML button

My private.xml

< ?xml version="1.0"?>
< root>
  < appdef>
    < appname>UNKNOWN< /appname>
    < !--
        Please modify bundle identifier for your environment.
        You can confirm it by EventViewer.
        https://pqrs.org/osx/karabiner/xml.html.en#appdef-steps
    -- >
    < equal>com.codeweavers.CrossOverHelper.< /equal>
  < /appdef>

  < item>
    < name>Disable all settings while you are using Cross Over applications< /name>
    < identifier>private.ignore_crossover< /identifier>
    < only>UNKNOWN< /only>
    < autogen>__PassThrough__< /autogen>
  < /item>
< /root>

UPDATED: For new Karabiner (JSON config) As long as my understanding is correct, you can exclude your virtual machines by using frontmost_application_if or frontmost_application_unless.

You can get working examples from https://pqrs.org/osx/karabiner/complex_modifications/ See "Emacs key bindings (rev 13)" which has a exclusion list in it.

More info: https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/conditions/frontmost-application/

4
palash kulshreshtha On

for my future self and others

I did the changes today to ignore emacs for for certain karabiner keybindings. I did that by opening the karabiner json config in ~/.config/karabiner/karabiner.json and adding

"^org\\.gnu\\.Emacs$"

in in each of the json conditions of type frontmost_application_unless conditions.

This way key bindings will work for all except emacs and other unless mentioned conditions.

similarly if you want to exclude any other application then you will have to open karabiner event viewer (after giving mac permissions) and then go to frontmost application.

Here when you will change the screen to the application then that application's address will be logged.

For eg when i changed my screen to joplin application i use. It showed following details (which i copied by clicking on copy to clip

net.cozic.joplin-desktop
/Applications/Joplin.app/Contents/MacOS/Joplin

So if you want to exclude joplin application then you will have to add "^net\.cozic\.joplin-desktop$"

Ps. ^ means that your matching regex starts with net

\\ is required so that we can escape single dot (.)

$ is required to denote that regex matching should end here.