Karabiner-Elements
Karabiner-Elements copied to clipboard
Is there a way to define a hotkey via karabiner-elements for Emacs Anywhere instead of using the shortcut from Apple's System Preferences?
I really like a software program called Emacs Anywhere!
Currently, I am following the instructions on the README file. Hence, I have defined a hotkey via macOS' GUI on SystemPreferences/keyboard/shortcut/services/general
.
However, I am managing all my hotkeys with Karabiner-elements. I like the text-driven approach via JSON file. This is my config file. It is way more reproducible.
If I re-store this machine (or buy a new one) or share my config with a friend, it is just necessary to paste the text content.
Thus, I would like to ask, is it possible to configure this with a shell command?
For instance, this is how I can open the Brave browser:
{
"description": "left_command + b -> Brave",
"manipulators": [
{
"from": {
"key_code": "b",
"modifiers": {
"mandatory": [
"left_command"
]
}
},
"to": [
{
"shell_command": "open '/Applications/Brave Browser.app'"
}
],
"type": "basic"
}
]
}
What would be the terminal shell command to invoke Emacs-anywhere on macOS? What command is triggered when I execute the shortcut defined on Apple's GUI System Preferences?
Thanks
What would be the terminal shell command to invoke Emacs-anywhere on macOS? What command is triggered when I execute the shortcut defined on Apple's GUI System Preferences?
Wouldn't you get a better answer if you asked this there? :-)
I opened 6 issues there in the last 20 days there and I got absolutely no replies. One of the questions was what I have posted here.
Is this question annoying for you in some way?
I can close the issue if so.
It has a workflow saved as a service in ~/Library/Services
. That's the one being run when you press assigned shortcut. The relevant part of that workflow is this shell script [1], which executes another script at the end [2].
[1] https://github.com/zachcurry/emacs-anywhere/blob/a3567288a14e1f1ceebfb0f3d134bbb72f676e73/Emacs%20Anywhere.workflow/Contents/document.wflow#L63-L70 [2] https://github.com/zachcurry/emacs-anywhere/blob/master/bin/run
Thank you for the explanation.
But, I am still lost here. I have this:
/Users/pedro/Library/Services/Emacs Anywhere.workflow/Contents:
total used in directory 24 available 114.4 GiB
drwxr-xr-x 5 pedro staff 160 Aug 4 11:42 .
drwxr-xr-x@ 3 pedro staff 96 Aug 4 11:42 ..
-rw-r--r-- 1 pedro staff 419 Aug 4 11:42 Info.plist
drwxr-xr-x 3 pedro staff 96 Aug 4 11:42 QuickLook
-rw-r--r-- 1 pedro staff 5259 Aug 4 11:42 document.wflow
How can I transform this content into a karabiner-element configuration in JSON?
You should be able to see what it does by opening that workflow using Automator. I looked into the content of document.wflow
, and it contained this shell script (1st link in my previous post):
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ -f "$HOME"/.bash_profile ]; then
source "$HOME"/.bash_profile
fi
source ~/.emacs_anywhere/bin/run
Try executing this; if it works, use this in to.shell_command
. You can move this into a seperate file, and execute that file in shell_command
if it makes the config cleaner.