yqrashawn / GokuRakuJoudo

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

Simultaneous keys with hyper to shell command #47

Closed lucaorio closed 4 years ago

lucaorio commented 4 years ago

I'd like to trigger a shell script by pressing hyper + space + left_arrow.

I've been trying to define the rule in different ways, but all of them trigger a ERROR: invalid <from> in main section.

How can I define such a rule?

nikitavoloboev commented 4 years ago

What is hyper?

lucaorio commented 4 years ago

Hey @nikitavoloboev ! :D

In the tutorial I found: ; !! | mandatory command + control + optional + shift (hyper) Is this my hyper key?

nikitavoloboev commented 4 years ago

Oh I see. I guess hyper means multiple modifiers.

[:!COTSspacebar "ls"] should trigger shell script on command + control + optional + shift + spacebar

Never actually done something like this so not sure. I am also not sure how to activate multiple keys from modifier key. Would wait for @yqrashawn to reply.

nikitavoloboev commented 4 years ago

P.S. would be cool to see your goku config :)

lucaorio commented 4 years ago

That works well, indeed!

I have the rule below (which works too), with my _rightalt that has been remapped to hyper. [:right_alt :!CTOleft_shift]

[:!!left_arrow "/usr/local/bin/yabai -m window --resize left:-20:0 ; /usr/local/bin/yabai -m window --resize right:-20:0"]

I would just like to add a spacebar in the mix :) But maybe I got the purpose of an hyper key all wrong?

I am finally going through some cleanup in my dotfiles, and I hope to be able to share my Goku config soon 👍

yqrashawn commented 4 years ago

You need to define a varible for hyper space first.

[:!!spacebar ["yabai-spacebar-mode" 1] nil {:afterup ["yabai-spacebar-mode" 0]}]
:yabai-spacebar-mode
[:left_arrow "/usr/local/bin/yabai -m window --resize left:-20:0 ; /usr/local/bin/yabai -m window --resize right:-20:0"]
lucaorio commented 4 years ago

@yqrashawn Is the example supposed to be a copy/paste solution? I couldn't get this to work, nor I was able to understand how to implement this properly.

I also took a look at the layer section where there's a similar example, but had no luck.

yqrashawn commented 4 years ago

Sorry for that. Please replace :left_arrow with :##left_arrow.

[:!!spacebar ["yabai-spacebar-mode" 1] nil {:afterup ["yabai-spacebar-mode" 0]}]
:yabai-spacebar-mode
[:##left_arrow "/usr/local/bin/yabai -m window --resize left:-20:0 ; /usr/local/bin/yabai -m window --resize right:-20:0"]
lucaorio commented 4 years ago

No worries, @yqrashawn ! I just copy/pasted that snippet in my rules, but it still doesn't work :(

lucaorio commented 4 years ago

I don't know if this helps, but I've been also trying to play with layers.

This works:

[:spacebar ["spacebar-mode" 1] nil {:afterup ["spacebar-mode" 0] :alone :spacebar}]
[:period "ls" ["spacebar-mode" 1]]

But this does not:

[:!!spacebar ["spacebar-mode" 1] nil {:afterup ["spacebar-mode" 0]}]
[:period "ls" ["spacebar-mode" 1]]
yqrashawn commented 4 years ago

Use :##period or :!!period instead of :period. So it will match any(##) or all modifier(!!) in spacebar-mode.

lucaorio commented 4 years ago

Apologies for the late reply! I finally had some time to test this, but I can confirm that all the solutions below do not work:

[:!!spacebar ["spacebar-mode" 1] nil {:afterup ["spacebar-mode" 0]}]
[:!!period "ls" ["spacebar-mode" 1]]
[:!!spacebar ["spacebar-mode" 1] nil {:afterup ["spacebar-mode" 0]}]
[:##period "ls" ["spacebar-mode" 1]]
[:!!spacebar ["spacebar-mode" 1] nil {:afterup ["spacebar-mode" 0]}]
:spacebar-mode
[:!!period "ls" ["spacebar-mode" 1]]
[:!!spacebar ["spacebar-mode" 1] nil {:afterup ["spacebar-mode" 0]}]
:spacebar-mode
[:##period "ls" ["spacebar-mode" 1]]

Eventually, it'd be great to know if I am setting this up wrongly or if it's an edge case in Goku.

In the meantime I am more than happy to remap my shortcuts to a single key rather than using the !! modifier. :)

yqrashawn commented 4 years ago

If these won't work, there might be rules conflict with these rules. Like there's rules that use period as trigger.

Checkout here

I use :!comma-mode and :!period-mode so that I can use tab key in those two modes.

lucaorio commented 4 years ago

@yqrashawn well this is awkward, and you were right! :D

I started from scratch to get to the root of the problem. It turns out I had a [:!!period "/usr/local/bin/mpc next"] buried in my config.

I will try to play around with this a bit more by following the logic you used in your dotfiles. The way I setup things right now doesn't allow me properly scale my config if I need to. Thanks!