GokuRakuJoudo icon indicating copy to clipboard operation
GokuRakuJoudo copied to clipboard

insert abstraction

Open yqrashawn opened this issue 5 years ago • 13 comments

Like this one.

[:!CSl [:!Cl :j :a :v :a :s :c :r :i :p :t :!Ssemicolon :return_or_enter]

to something like

[:!CSl [:!Cl [:insert "javascript:"] :return_or_enter]

Why

Insert with applescript is slow.

Problem

    1. can't support keys like return_or_enter
    1. keys like !, @ might be affected by keyboard layout.

https://app.leanboard.io/board/68a43769-52d6-4b64-b752-7f44b59125a3

yqrashawn avatar Jun 10 '19 02:06 yqrashawn

It should also support capital letters.

nikitavoloboev avatar Jun 10 '19 07:06 nikitavoloboev

Just found this. https://gist.github.com/ethack/110f7f46272447828352768e6cd1c4cb

We can use

 :templates {:type "osascript -e 'tell application \"System Events\" to keystroke \"%s\" as text'"}

for inserting texts.

yqrashawn avatar Nov 21 '19 10:11 yqrashawn

Very awesome, will try now. Hope it's the same speed.

nikitavoloboev avatar Nov 21 '19 10:11 nikitavoloboev

Can’t press with modifier keys though.

yqrashawn avatar Nov 21 '19 11:11 yqrashawn

I did :i "osascript -e 'tell application \"System Events\" to keystroke \"%s\" as text'"

And then tried to use it:

[:a [:i "console.log"]]

It doesn't work though. Am I doing something wrong?

nikitavoloboev avatar Nov 21 '19 11:11 nikitavoloboev

Okay fixed it by giving it permissions:

https://apple.stackexchange.com/questions/291574/osascript-is-not-allowed-assistive-access-1728

nikitavoloboev avatar Nov 21 '19 11:11 nikitavoloboev

I am trying to insert text and then do left keystroke:

[:a [:i "console.log()" :left_arrow]]

I would think above would work but it doesn't. Do you know why?

nikitavoloboev avatar Nov 21 '19 11:11 nikitavoloboev

Okay never mind, the applescript is slower than [:!CSl [:!Cl :j :a :v :a :s :c :r :i :p :t :!Ssemicolon :return_or_enter].

So the solution still stands.

I would like native way for Goku to translate inputs and translate it to raw calls of keystrokes called.

nikitavoloboev avatar Nov 21 '19 11:11 nikitavoloboev

I think it's not the best solution to map strings to karabiner key sequence. There are tools like espanso, there must be ways to use the system clipboard or other tools.

yqrashawn avatar Mar 04 '20 02:03 yqrashawn

Seems there's no way to just use the paste functionality of macOS without using Applescript due to the sandbox feature in macOS. We need to integrate with other apps like espanso or write a real macOS app.

The idea is to config at least part of espanso using goku, maybe through a espanso.edn file.

yqrashawn avatar Mar 29 '20 14:03 yqrashawn

Why can't goku transform a [:insert "javascript:"] to direct calls to each of the keys?

No need for AppleScript at all. Just need a parser that will go through string and map each character to a separate key code like :j :a and etc

nikitavoloboev avatar Mar 29 '20 16:03 nikitavoloboev

There will be a lot of limitations. Like not being able to insert emoji. Or can't insert characters in more than languages at the same time.

yqrashawn avatar Mar 31 '20 14:03 yqrashawn

even with the limitations stated above it will be quite useful

alexey-danilov avatar Aug 06 '20 04:08 alexey-danilov