Open januz opened 1 year ago
@januz, you could try
{
:des "simultaneous jk/kj press to enter kindaVim normal mode"
:rules [:!kVNormal
[[:j :k] :!!equal_sign [:!kitty :!terminal :!vimr]]]
}
@yqrashawn, I have similar issue with combining several conditions, for example below is not working
:main [{:des "loremipsum"
:rules [:g-mode
[:slash :!Cslash [:Element :Discord]]]}]
:applications {:Discord ["^com\\.hnc\\.Discord$"]
:Element ["^im\\.riot\\.app$"]}
}
Seems goku don't support combine multiple application conditions like this. You can combine multiple regex as one app for this purpose for now. like this one
I have also encountered this problem, so let's regroup.
@yqrashawn
You can combine multiple regex as one app for this purpose for now
I tried this but it also did not work for me. Currently, I don't know whether there is a way to get the behavior I would like to have.
Thanks for looking into it!
@januz this should work, mind sharing your config so we can troubleshoot it.
@bangedorrunt I have this in my karabiner.edn
:
{
:applications
{
:kitty ["^net\\.kovidgoyal\\.kitty$"]
:terminal ["^$com\\.apple\\.Terminal"]
:vimr ["^$com.\\qvacua.\\VimR"]
:safari ["^com\\.apple\\.Safari$"]
:needjk [
"^net\\.kovidgoyal\\.kitty$"
"^$com\\.apple\\.Terminal"
"^$com.\\qvacua.\\VimR"
]
}
:main
[
{
:des "simultaneous jk/kj press to enter kindaVim normal mode"
:rules [
[
[:j :k] :!!equal_sign
[:!kVNormal :!needjk]
]
]
}
{
:des "simultaneous jk/kj to exit kindaVim normal mode"
:rules [
[
[:j :k] :i
[:kVNormal :!needjk]
]
]
}
]
}
What I want to do is activate KindaVim (by remapping jk/kj to the shortcut I have set up to activate kindaVim, Cmd-Ctrl-Shift-=) if KindaVim is not in normal mode (the kVNormal
variable is set by Hammerspoon) AND if the application is not one that has their own internal jk/kj remapping, e.g., kitty, VimR, etc.). The same for the second mapping for deactivating KindaVim.
Please let me know if I'm understanding something incorrectly and thanks for your help!
@januz I don't think kvNormal
will communicate with Karabiner as you expected. You can open Karabiner Event Viewer to see list of available variables for your current setup. I'm not with computer and not using KindaVim atm but I believe we could have a workaround to resolve your prob
https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/conditions/variable/#confirm-the-current-variable-values
@bangedorrunt It works if I just use [:kvNormal]
so the variable can definitely be seen by Karabiner Elements. The problem only occurs if I combine this condition with an application condition (because I don't want the mapping to be effective in certain applications). Thanks for your help!
Oh, it's interesting, first time I learnt that we can use shell variables as condition. So you can try the following to see if it works. Sorry I'm on mobile
{
:applications
{
:kitty ["^net\\.kovidgoyal\\.kitty$"]
:terminal ["^$com\\.apple\\.Terminal"]
:vimr ["^$com.\\qvacua.\\VimR"]
:safari ["^com\\.apple\\.Safari$"]
:needjk [
"^net\\.kovidgoyal\\.kitty$"
"^$com\\.apple\\.Terminal"
"^$com.\\qvacua.\\VimR"
]
}
:main
[
{
:des "simultaneous jk/kj press to enter kindaVim normal mode"
:rules [
:needjk
[
[:j :k] :!!equal_sign
:!kVNormal
]
]
}
{
:des "simultaneous jk/kj to exit kindaVim normal mode"
:rules [
:!needjk
[
[:j :k] :i
:kVNormal
]
]
}
]
}
Oh, it's interesting, first time I learnt that we can use shell variables as condition
Well, it's not a shell variable. It's a Karabiner variable that is set using Hammerspoon as described here
can try the following to see if it works
Unfortunately, no. It has the same effect, i.e., the mapping not being active at all, independent of current application.
Hi @bangedorrunt, the application identifier "^$com\\.apple\\.Terminal"
is a regex expression.
"^$com\\.apple\\.Terminal"
should be changed to "^com\\.apple\\.Terminal$"
^
is indicating to match the start
$
is to match the end
@bangedorrunt You can find these (some of) identifiers in my config https://github.com/yqrashawn/yqdotfiles/blob/1b52767ec4f539926ac997cdffd8b3115700d83e/modules/yqrashawn/home-manager/dotfiles/karabiner.edn#L805
It's my bad that overlooked the incorrect patterns. Yes, I'm well aware of regex syntax. I believe this could fix @januz issue. Many thanks @yqrashawn for clarification. Goku is simply the best 😘
@yqrashawn Thanks for noticing the typos in the regexes. However fixing them does not resolve the problem:
Thanks for your help!
@yqrashawn Sorry to bug you again with this issue but is there any way I can use Goku to specify conditions that combine variable and application conditions?
I was very happy to find
goku
. Makes using Karabiner Elements much easier! I have the following issue though: I would like to remap a key combination only if several conditions are metBased on the tutorial, I thought this would be possible with
or
but neither seems to work. If I only use the variable condition based on
kVNormal
, the mapping works (but I need it not to be active in certain applications).Thanks for your help!