Open rggjan opened 7 years ago
I need exactly the same thing. Now, I have to disable all the other devices completely in the "Devices" tab in order to prevent that my rules apply to these devices also. I should be possible to restrict complex rules to individual devices.
It's a workaround, but not exactly the same thing. With this solution, it's not possible to have different complex modifications for different devices at the same time (i.e. in the same profile).
I think with the old Karabiner this was possible. You just defined a set of applications and a set of devices, and then you could restrict each rule to an application and a device. With the new Karabiner-Elements, each complex modification rule can be restricted to an application, but not to a device.
2017-11-03 9:04 GMT+01:00 nguyenhimself notifications@github.com:
Isn't that how 'Profiles' already works currently? I have 4 sets of configs and complex rules on my machine.
In fact, thanks to an automatically-enabled macro in Keyboard Maestro, I don't even need to do anything. Just plug in an external keyboard and the correct profile is selected.
[image: screen shot 2017-11-03 at 3 00 27 pm] https://user-images.githubusercontent.com/482270/32364510-d7f6b25a-c0a7-11e7-8dad-ecf31a0d4bfa.png
[image: screen shot 2017-11-03 at 3 03 13 pm] https://user-images.githubusercontent.com/482270/32364557-243ae5e6-c0a8-11e7-91ec-a30c2cbef0c4.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tekezo/Karabiner-Elements/issues/1073#issuecomment-341640964, or mute the thread https://github.com/notifications/unsubscribe-auth/ACSQMG3AOt1jxKcEXbNGhcne18ZMFejfks5syskcgaJpZM4QKyGx .
I just saw that it is actually possible with the "device_if"
condition in complex modification rules, as demonstrated here (referenced from #979).
So, I think this issue can be closed.
@weibeld Great to know there is a way to do it. However, I still think this is not very user friendly, especially when importing rules from the Internet: These would have to be downloaded, manually edited by hand and then reimported into Karabiner-Elements again, right? Not something the average user can do when he imports some predefined rules from others...
Yes, basically. When you import a rule from the Internet through the Karabiner-Elements GUI, it gets saved as a JSON file in the following directory (this is also where you save your own rules):
~/.config/karabiner/assets/complex_modifications
There you can edit it by hand, and then you can enable the rule in the GUI (if you already enabled it before, then you have to remove the rule and add it again in order to reload the changes).
I think too it's not very user-friendly. There should be a section in the UI where you can declare devices (by their vendor ID and product ID) and a section where you can declare apps (by their app ID). And then there should be a function in the GUI to freely add devices and/or apps to individual rules, to restrict the rules to these devices/apps.
Also, now you have to repeat each device/app condition for each keystroke inside a rule, which I think is unnecessary too. It would be enough to set device and app conditions for an entire rule as a whole.
Thanks for the explanation! I agree it would be better to be able to do this in the GUI. It is already possible for the simple rules, so this shouldn't be too hard to implement, or am I wrong?
I'm not familiar with the source code, I think it would require some substantial changes, but certainly it's not impossible.
I also think JSON is not a good idea for configuration files that are supposed to be edited by hand. That's one of the first things I would change too.
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.
Still interested in this, please don't close it
This looks related to (and maybe a dupe of) https://github.com/tekezo/Karabiner-Elements/issues/979?
No, #979 is still about modification of the json file. I would like to see it in the UI instead... On Wed, 7 Mar 2018 at 01:15, Danny Weinberg notifications@github.com wrote:
This looks related to (and maybe a dupe of) #979 https://github.com/tekezo/Karabiner-Elements/issues/979?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tekezo/Karabiner-Elements/issues/1073#issuecomment-370976266, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH2Ks1V44l5kMsn82HIw5V0ijgH8OK3ks5tbyaTgaJpZM4QKyGx .
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.
Still interested in this, please don't close...
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.
Still interested in this, please don't close...
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.
Still interested in this, please don't close...
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.
Maybe I should write a bot which keeps replying to the other bot that I'm still interested in this feature... 😜
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.
Still interested in this, please don't close...
Also interested please don't close
Very interested in this
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.
Still interested in this
I'd really like to see this as well, and am glad to see there's an issue for it.
interested as well. Hope somebody figure this out somehow
This is already implemented as the device_if condition (can someone copy to the top). @rggjan can you update your question description with the answer - Thanks!!
See:
"conditions": [
{
"type": "device_if",
"identifiers": [
{
"vendor_id": 1278,
"product_id": 515
}
]
}
],
Hi @idvorkin. Thanks! However, I'm specifically asking for making this possible via UI (eg download and activate a predefined complex modification for only one device vi UI, without messing with config files). Sorry for not being clear about that.
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.
I am also interested in a UI method of setting this. I don’t want to go update a bunch of .json files every time I plug a different keyboard in
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.
This issue has been automatically marked as not stale because @rggjan is still interested in this. Thank you for your understanding.
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.
This issue has been automatically marked as not stale because @rggjan is still interested in this. Thank you for your understanding.
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.
This issue has been automatically marked as not stale because @rggjan is still interested in this. Thank you for your understanding.
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.
Ok, bot. Could you close this issue one more time next month, please?
I also need this functionality. My external keyboard is set up beautifully but when using the built-in keyboard I need stuff like caps+hjkl -> arrow keys.
Keeping the dream alive.
I just saw that it is actually possible with the
"device_if"
condition in complex modification rules, as demonstrated here (referenced from #979).So, I think this issue can be closed.
The link here is not found anymore. Could some please post an example using "device_if"
?
--- Edit ---
Worked out how to do it with complex modifications:
Here's how to swap the " and the @ on a specific external keyboard only
"complex_modifications": {
"parameters": {
"basic.simultaneous_threshold_milliseconds": 50,
"basic.to_delayed_action_delay_milliseconds": 500,
"basic.to_if_alone_timeout_milliseconds": 1000,
"basic.to_if_held_down_threshold_milliseconds": 500,
"mouse_motion_to_scroll.speed": 100
},
"rules": [
{
"description": "At to quote",
"manipulators": [
{
"conditions": [
{
"type": "device_if",
"identifiers": [
{
"vendor_id": 1241,
"product_id": 17733
}
]
}
],
"from": {
"key_code": "2",
"modifiers": {
"mandatory": [
"shift"
]
}
},
"to": [
{
"key_code": "quote",
"modifiers": ["shift"]
}
],
"type": "basic"
}
]
},
{
"description": "Quote to at",
"manipulators": [
{
"conditions": [
{
"type": "device_if",
"identifiers": [
{
"vendor_id": 1241,
"product_id": 17733
}
]
}
],
"from": {
"key_code": "quote",
"modifiers": {
"mandatory": [
"shift"
]
}
},
"to": [
{
"key_code": "2",
"modifiers": ["shift"]
}
],
"type": "basic"
}
]
}
]
},
I just saw that it is actually possible with the
"device_if"
condition in complex modification rules, as demonstrated here (referenced from #979). So, I think this issue can be closed.The link here is not found anymore. Could some please post an example using
"device_if"
?--- Edit ---
Worked out how to do it with complex modifications:
Here's how to swap the " and the @ on a specific external keyboard only
"complex_modifications": { "parameters": { "basic.simultaneous_threshold_milliseconds": 50, "basic.to_delayed_action_delay_milliseconds": 500, "basic.to_if_alone_timeout_milliseconds": 1000, "basic.to_if_held_down_threshold_milliseconds": 500, "mouse_motion_to_scroll.speed": 100 }, "rules": [ { "description": "At to quote", "manipulators": [ { "conditions": [ { "type": "device_if", "identifiers": [ { "vendor_id": 1241, "product_id": 17733 } ] } ], "from": { "key_code": "2", "modifiers": { "mandatory": [ "shift" ] } }, "to": [ { "key_code": "quote", "modifiers": ["shift"] } ], "type": "basic" } ] }, { "description": "Quote to at", "manipulators": [ { "conditions": [ { "type": "device_if", "identifiers": [ { "vendor_id": 1241, "product_id": 17733 } ] } ], "from": { "key_code": "quote", "modifiers": { "mandatory": [ "shift" ] } }, "to": [ { "key_code": "2", "modifiers": ["shift"] } ], "type": "basic" } ] } ] },
I got the Apple Internal Keyboard's product_id and vendor_id in hexadecimal, and I transformed to decimalism, but It doesn't seem to work.
{
"title": "Escape Key",
"rules": [
{
"description": "Escape key (grave_accent_and_tilde as Escape and fn + grave_accent_and_tilde as grave_accent_and_tilde)",
"manipulators": [
{
"type": "basic",
"conditions": [
{
"type": "device_if",
"identifiers": [
{
"vendor_id": 1452,
"product_id": 635
}
]
}
],
"from": {
"key_code": "grave_accent_and_tilde",
"modifiers": {
"mandatory": [
"fn"
],
"optional": [
"caps_lock"
]
}
},
"to": [
{
"key_code": "grave_accent_and_tilde"
}
]
},
{
"type": "basic",
"from": {
"key_code": "grave_accent_and_tilde"
},
"to": [
{
"key_code": "escape"
}
]
}
]
}
]
}
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.
This issue has been automatically marked as not stale because @rggjan is still interested in this. Thank you for your understanding.
Ah!
https://github.com/pqrs-org/Karabiner-Elements/issues/1073#issuecomment-342208484:
--snip-- I think too it's not very user-friendly. There should be a section in the UI where you can declare devices (by their vendor ID and product ID) and a section where you can declare apps (by their app ID). And then there should be a function in the GUI to freely add devices and/or apps to individual rules, to restrict the rules to these devices/apps. --snip--
+1. This would be great!
for anyone who comes across this in the future - I have a satechi bluetooth keypad and a Matias tactile pro keyboard. Both are showing as the same vendor (apple) and product even though they aren't. I think that is because they have a generic apple driver.
"product_id": 544,
"vendor_id": 1452
In order to differentiate the keys coming from the keypad vs the keyboard I had to use the location_id as a param to device_if. location_id isn't permanent so I have a daemon that runs and modifies the json to set the location_id to the new location_id of the keypad if it changes.
**--snip-- location_id isn't permanent so I have a daemon that runs and modifies the json to set the location_id to the new location_id of the keypad if it changes.
If you don't mind, can you share the code?
@MuhammedZakir - will post code tomorrow when I'm back at my desk. Need to clean it up a bit and factor it out to be standalone
There are some complex modifications (rules) I would like to enable only on my external keyboard. It would be great if this could be enabled, the same way as the simple modifications and Function keys can be set individually per device.