New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I define and execute my own shell scripts in Karabiner Elements? #721
Comments
Elements is currently not able to do that. It basically just maps keys to key functions, as in the things a key can do, including stuff like If you're willing to edit the XML file directly, you can access functionality not yet available in the GUI, but I'm not sure if you can assign keys to scripts like that yet. There's some support for binding shortcuts to scripts built into macOS. Check out this SO post. This is pretty much every option Elements currently offers:
Karabiner Elements still supports inverting the function keys, where F1 is just F1, and you hold fn and hit F1 for The Event Viewer from the old version is also available. |
Thanks a lot for this (high-level) summary. Any chance this would be a good addition to the readme, in case others are wondering about this as well? |
Thanks. I'm only a user, so have no control over what goes in the README, but I did write this in the hope it would answer your question and offer a quick status report for anyone else that comes here. |
@carlsmith Perhaps you can make a pull request |
Done (#724). Thanks guys. |
@carlsmith |
@carrigmore - Yep. You can. It's easy to do just using the GUI. Under the Simple Modifications tab, if you hit the Add item button, you get two drop down menus, From key and To key. In those, there's a section named Keypad keys, and keypad_num_lock is the first item. Just select that from the From key menu, and select whatever you want it mapped to from To key. I tested just mapping it to x, and it worked fine. It's pretty straight forwards, but let me know if you have any trouble. |
Currently in element It can only map to a 'pc_sroll_lock' but not 'num_lock', you see the screenshot, the pc number lock key is not in the list. |
@carlsmith I find user can edit the JSON file, but for some reason cannot map a key to windows locking_num_lock. As it has "not_to" : true { |
I'm on my phone, but as far as I know, the Clear key on a Mac literally is the Numlock key. Keyboards don't know what their keys do. They just report that the key at the top left of the numpad was pressed, and the OS, based on layout software, determines what that key does, so there's no distinction between Clear and Numlock at the keyboard or driver (Karabiner) level. The legends on the keys are only a visual add that must assume a certain layout has been chosen in software. That's my understanding, but I may have totally misunderstood the issue. I'm new to this stuff. |
Sorry. Just read your message again. Ignore what I just wrote. I didn't even know it was possible to toggle Numlock state on macOS, so will have to just hope someone who knows better can help you out. Presumably, the missing Numlock key in the PC submenu was just an oversight that can be added without much trouble. |
Might be worth opening a new issue. |
@carlsmith thanks a lot, I already created an issue. |
@carlsmith in the Karabiner we can achieve this. The NumLock LED on keyboard will light up and the number pad keys can be used. This is quite useful when using a compact keyboard where number pad is used for multiple purposes (like TK quickfire, the number pad has other functions, if not toggled correctly cannot be used to input numbers) |
The TK Quickfire looks really cool. I'd not seen a keyboard with that layout before. My main driver's an ANSI MINILA, so I get that some of the features most people never use can be important on smaller keyboards. It's interesting that macOS supports Numlock. There's a popular ruby script on GitHub Gist somewhere that toggles the Caps Lock and Scroll Lock LEDs on the MINILA, well, on any keyboard. It'd be nice if I could get the Scroll Lock LED to indicate some other, actually useful state. |
Shell commands are back in version 0.91.7. For example use "shell_command": "open '/Applications/Safari.app'" in the "to" section of the intended key combination (replacing "key_code: "x"). |
@HRG1 That's the feature I've been waiting for! This is glorious! There seem to be few examples of user-edited karabiner.json for complex rules. Are they being collected as documentation? I've set mine up to have certain key commands launch new windows of certain applications (distinct from launching the application). It's entirely possible I just looked in the wrong places. |
@smlewis Could you share your solution? I am trying to map |
@jerguslejko I uploaded my JSON to this repository and the other one (that lets you pull complex configs down from the GUI). That JSON should get you started on your needs! You should be able to see how to add in your complex_modification manually. I guess you can edit it from scratch, or pull the one I put in KE-complex_modifications and copy and edit that. |
Thank you @smlewis! I managed to get it working. For anyone wondering, I was trying to remap my Here is my `~/.config/karabiner/karabiner.json` config{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
"basic.to_if_alone_timeout_milliseconds": 1000
},
"rules": [
{
"description": "map caps_lock to escape",
"manipulators": [
{
"from": {
"key_code": "caps_lock"
},
"to": [
{
"key_code": "escape"
}
],
"type": "basic"
}
]
},
{
"description": "play bell sound when pressing the escape key",
"manipulators": [
{
"from": {
"key_code": "escape"
},
"to": [
{
"shell_command": "osascript -e 'beep'"
}
],
"type": "basic"
}
]
}
]
},
"devices": [],
"fn_function_keys": {
"f1": "display_brightness_decrement",
"f10": "mute",
"f11": "volume_decrement",
"f12": "volume_increment",
"f2": "display_brightness_increment",
"f3": "mission_control",
"f4": "launchpad",
"f5": "illumination_decrement",
"f6": "illumination_increment",
"f7": "rewind",
"f8": "play_or_pause",
"f9": "fastforward"
},
"name": "Default profile",
"selected": true,
"simple_modifications": {},
"virtual_hid_keyboard": {
"caps_lock_delay_milliseconds": 0,
"keyboard_type": "ansi"
}
}
]
} |
I came here looking for how to execute scripts from Karabiner Elements shortcut in Sierra (like I was able to do with Karabiner in El Capitan) and having looked at the examples given by folks I wanted to add one which was of interest to me and may be to others.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@danfrincu Thanks, you gave me the bread crumbs to solve my issue. |
Hi
I don't know what I should expect to work if I'd go from Karabiner (currently working, didn't upgrade to Sierra) to Karabiner Elements. The readme doesn't seem to mention it, or I didn't know where to look -- apologies if it's the latter.
I'm using Karabiner for one things mainly: executing shell commands and AppleScript commands, bound to global or app specific shortcuts, i.e. using commands I defined in
private.xml
.Is the current version of Elements able to do this, or is this one of the parts not implemented yet?
The text was updated successfully, but these errors were encountered: