pqrs-org / KE-complex_modifications

Karabiner-Elements complex_modifications rules
https://ke-complex-modifications.pqrs.org/
The Unlicense
1.32k stars 1.1k forks source link

Function key / complex modification (Question not issue) #704

Closed Toadby closed 4 years ago

Toadby commented 4 years ago

Hi! So in the "Function keys" tab there is is an option to use the F1-12 keys as standard function keys, and have fn+F1-12 bind to the keys' special features. I would like to set up a rule to have this feature enabled only when a certain application is selected. I have tried remapping F1 by mapping 112 to 58, as well as mapping 112 to fn+112. This might be an issue with the game (the application I want to use this for is a game) because I also tried binding 112 to "w" and couldn't move forward with it. It just functioned as the normal brightness decrement. When I had it bound to 58, it didn't do anything at all. I could also just be writing my rules wrong so I will put the simplest one (112 -> w) below. The thing is when I use the checkbox, it works fine and does what it should! So I would love to sort out a way to essentially just have that checkbox apply for the one application.

Even if I don't end up being able to do this, I've already accomplished what I wanted to when I downloaded the application - just with simple modifications - so I'm totally happy! Thanks :)


  "title": "Function Key Swap",
  "rules": [
    {
      "description": "f1 -> w",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": 112
          },
          "to": {
            "key_code": "w"
          },
          "conditions": [
            {
              "type": "frontmost_application_if",
              "bundle_identifiers": [
                "^net\\.java\\.openjdk\\.cmd"
              ]
            }
          ]
        }
      ]
    }
  ]
}```
This didn't seem to do anything, and the F1 key still functioned as brightness decrement. I have tried this with and without checking for the application being active.
stale[bot] commented 4 years ago

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.

harmtemolder commented 4 years ago

I actually built the same thing for a couple of my apps:

{
  "title": "(Atom, iTerm, muCommander, PyCharm, Crusader Kings II) Use function keys as function keys",
  "maintainers": [
    "harmtemolder"
  ],
  "rules": [{
    "description": "(Atom, iTerm, muCommander, PyCharm, Crusader Kings II) Use function keys as function keys",
    "manipulators": [{
        "type": "basic",
        "from": {
          "key_code": "f1",
          "modifiers": {
            "optional": [
              "any"
            ]
          }
        },
        "to": [{
          "key_code": "f1"
        }],
        "conditions": [{
          "type": "frontmost_application_if",
          "file_paths": [
            "ck2\\.app"
          ],
          "bundle_identifiers": [
            "com.github.atom",
            "com.mucommander.muCommander",
            "com.googlecode.iterm2",
            "com.jetbrains.pycharm"
          ]
        }]
      },
      {
        "type": "basic",
        "from": {
          "key_code": "f2",
...

I use this with the checkbox unchecked and it works.

Hope this helps you get it sorted and I might just add my implementation to the repository.

Toadby commented 4 years ago

Thank you! It looks like your code got cut off - I can't click the 3 dots at the bottom to expand...

Toadby commented 4 years ago

I am new to bundle identifiers so if you have any info on getting the ID from an active app, that would be useful! I am working with Minecraft, which has a launcher that then runs the game. I can find the ID for the launcher but I'm confused by the game just running as "java" :') I can probably take a look at this later and see if I can remove the "frontmost_application_if" condition though!

harmtemolder commented 4 years ago

Thank you! It looks like your code got cut off - I can't click the 3 dots at the bottom to expand...

I cut it off on purpose, from there it just repeats itself 12 times (for all 12 function keys). Sorry for not explaining that.

I am new to bundle identifiers so if you have any info on getting the ID from an active app, that would be useful! I am working with Minecraft, which has a launcher that then runs the game. I can find the ID for the launcher but I'm confused by the game just running as "java" :') I can probably take a look at this later and see if I can remove the "frontmost_application_if" condition though!

Have you tried “Launch EventViewer...” when you click the Karabiner icon in your menu bar? That has a “Frontmost application” tab. Keep that open and switch to Minecraft. Hope that helps.

Toadby commented 4 years ago

Ah thank you! I forgot about the EventViewer :) Looks like I'll have to use the application path because no identifier showed up, but now I know that that's an option too ! "bundle_identifier": "", "file_path": "/path/to/file" Thanks for your responses! I am working on other stuff rn but I should be able to recreate your method when I get around to it :) appreciate the help

harmtemolder commented 4 years ago

@Toadby It's not reflected on https://ke-complex-modifications.pqrs.org/ yet, but I added my setup to the repository. You should be able to import it by pasting this into your browser's address bar:

karabiner://karabiner/assets/complex_modifications/import?url=https://raw.githubusercontent.com/pqrs-org/KE-complex_modifications/master/public/json/function_keys.json

After importing, you can find and edit it in ~/.config/karabiner/assets/complex_modifications.