GokuRakuJoudo
GokuRakuJoudo copied to clipboard
insert abstraction
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
-
- can't support keys like
return_or_enter
- can't support keys like
-
- keys like
!
,@
might be affected by keyboard layout.
- keys like
https://app.leanboard.io/board/68a43769-52d6-4b64-b752-7f44b59125a3
It should also support capital letters.
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.
Very awesome, will try now. Hope it's the same speed.
Can’t press with modifier keys though.
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?
Okay fixed it by giving it permissions:
https://apple.stackexchange.com/questions/291574/osascript-is-not-allowed-assistive-access-1728
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?
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.
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.
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.
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
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.
even with the limitations stated above it will be quite useful