yqrashawn / GokuRakuJoudo

config karabiner with ease
GNU General Public License v3.0
1.16k stars 119 forks source link

adding rules for held + alone + selective mapping #55

Closed kaushikgopal closed 4 years ago

kaushikgopal commented 4 years ago

I'm trying to "supercharge" my caps lock key with the following behavior:

  1. if tapped alone - send escape key
  2. if held - emulate left_control
  3. if held in combination with some specific letters (for e.g. caps_lock + j -> send down_arrow)

Any 2 of the above conditions is possible, but if i want to write a goku rule to encompass all 3, i can't seem to find a way to do it, without tediously jotting down all the possible combinations? seems like i'm missing something basic in the way i have my rules listed out. Currently what i have:

:layers {
    :homerow-mode {:key :caps_lock :alone {:key :escape}}
} ;; layers

:main [

    {:des "CapsLock: vim navigation"
     :rules [:homerow-mode
                [:h :left_arrow]
                [:j :down_arrow]
                [:k :up_arrow]
                [:l :right_arrow]
                [:!Sh :!Sleft_arrow]
                [:!Sj :!Sdown_arrow]
                [:!Sk :!Sup_arrow]
                [:!Sl :!Sright_arrow]
                [:!Ch :!Cleft_arrow]
                [:!Cj :!Cdown_arrow]
                [:!Ck :!Cup_arrow]
                [:!Cl :!Cright_arrow]
                [:!CSh :!CSleft_arrow]
                [:!CSj :!CSdown_arrow]
                [:!CSk :!CSup_arrow]
                [:!CSl :!CSright_arrow]
                [:!Oh :!Oleft_arrow]
                [:!Oj :!Odown_arrow]
                [:!Ok :!Oup_arrow]
                [:!Ol :!Oright_arrow]
                [:!OSh :!OSleft_arrow]
                [:!OSj :!OSdown_arrow]
                [:!OSk :!OSup_arrow]
                [:!OSl :!OSright_arrow]
     ]}

]

I feel there's got to be a better way to say, default to left_control when held, but under special cirucmstances do a different action

kaushikgopal commented 4 years ago

i tried this but it doesn't seem to have an effect from the left_control perspective:

    {:des "caps lock: alone: escape; held: ctrl"
     :rules[
        [:##caps_lock nil nil {:alone :escape :held :left_control} ]
     ]
    }

I know this should be theoretically possible with Karabiner-Elements cause there's a complex json rule (apparently) that works for this case.

Would love to learn how to elegantly express this with goku 🙏

kaushikgopal commented 4 years ago

I realize just adding the two separate rules, seems to do the trick?

    {:des "caps lock -> ctrl"
     :rules [
        [:##caps_lock :left_control nil {:alone :escape}]
        [:!Th   :left_arrow]
        [:!Tj   :down_arrow]
        [:!Tk   :up_arrow]
        [:!Tl   :right_arrow]
        [:!TSh  :!Sleft_arrow]
        [:!TSj  :!Sdown_arrow]
        [:!TSk  :!Sup_arrow]
        [:!TSl  :!Sright_arrow]
        [:!TCh  :!Cleft_arrow]
        [:!TCj  :!Cdown_arrow]
        [:!TCk  :!Cup_arrow]
        [:!TCl  :!Cright_arrow]
        [:!TCSh :!CSleft_arrow]
        [:!TCSj :!CSdown_arrow]
        [:!TCSk :!CSup_arrow]
        [:!TCSl :!CSright_arrow]
        [:!TOh  :!Oleft_arrow]
        [:!TOj  :!Odown_arrow]
        [:!TOk  :!Oup_arrow]
        [:!TOl  :!Oright_arrow]
        [:!TOSh :!OSleft_arrow]
        [:!TOSj :!OSdown_arrow]
        [:!TOSk :!OSup_arrow]
        [:!TOSl :!OSright_arrow]
    ]}

Not sure if there's a more elegant way to express this, but this should work in terms of satisfying my requirements.

yqrashawn commented 4 years ago

This is my preferred way. You can also set a variable in caps_lock to section.

[:##caps_lock ["super_caps_mode" 1] nil {:alone :escape}]

But then you need to map each key in super_caps_mode and also those that you want to fallback to control.