GithubHelp home page GithubHelp logo

al-ce / karaml Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 0.0 478 KB

Write and update your Karabiner-Elements config in YAML

License: MIT License

Python 100.00%
karabiner karabiner-configurator karabiner-elements keyboard-layout macos python

karaml's People

Contributors

al-ce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

karaml's Issues

Descriptions

Have you thought at all about supporting rule descriptions for? I'm not sure how I'd implement them since I don't think I'd want to have to turn /layer/ into a dictionary with descriptions (string) and items (list). However, some way to support it might make things a little easier to work with in Karabiner's UI itself.

`shell_command` issues: restart the KE Console User Server

If you're having issues executing shell_command maps but your karaml map looks correct (and you confirmed this isn't a bug in karaml itself by checking it was translated correctly intokarabiner.json) try executing the following in your terminal:

launchctl kickstart -k gui/$(id -u)/org.pqrs.karabiner.karabiner_console_user_server

This will restart the Karabiner-Elements Console User Server launchd job for the current user.

I need to do this on occasion after using my quick-symbols layer (for ⌘⌃⇧⌥ etc). Have not been able to figure out why this happens. No results for the relevant error message in KE's issues:

[2023-04-19 20:46:20.361] [error] [console_user_server] shell_command stderr:execution error: Can’t make some data into the expected type. (-1700)

See #2 (comment)

`TT(layer)` and more QMK-layer-esque features

(storing my TODOs and thought processes in the issues)

Looking at the QMK Layers documentation, karaml has ways to simulate the following:

  • MO(layer) - momentarily activates layer. As soon as you let go of the key, the layer is deactivated.
    • Handled by/layer/ in the second position
  • TG(layer) - toggles layer, activating it if it's inactive and vice versa
    • Handled by /layer/ in the first position

The following can be achieved but in a hacky messy way or are not possible atm:

One-Shot Layer

  • OSL(layer) - momentarily activates layer until the next key is pressed. See One Shot Keys for details and additional functionality.

In Karaml:

/git/:
  g: var(git_layer, 0) + notify(idgit,)    # Turn off Git layer

  m: string(git checkout main) + CR + var(git_layer, 0)
  l: string(git log) + CR + var(git_layer, 0)
  # etc.

We could do something like automatically duplicate the entire /git/ layer in a /git_OSL/ and add the var() event, and have OSL(git) activate /git_OSL/ instead of /git/, but as far as the configuration is concerned it just looks like editing the /git/ layer.

Tap-Toggle

  • TT(layer) - Layer Tap-Toggle. If you hold the key down, layer is activated, and then is de-activated when you let go (like MO). If you repeatedly tap it, the layer will be toggled on or off (like TG). It needs 5 taps by default, but you can change this by defining TAPPING_TOGGLE -- for example, #define TAPPING_TOGGLE 2 to toggle on just two taps.

Needing multiple taps to activate a layer would be a nightmare (you'd need to create a layer that measures each tap) and then, since I have yet to implement to_delayed_action, there's no time-out to reset the count.

Here's what it looks like with just two taps:

/base/:
  <a-j>: [/helper/, /target/]
/helper/:
  <a-j>: var(target_layer, 1) + var(helper_layer, 0)

/target/:
  <a-j>: var(target_layer, 0)

Translation:
From base layer, if j is held, /target/ is turned on, and then off on release. If it's tapped, j turns on the /helper/ layer. From the helper layer, a second j tap turns on the /target/ layer and turns off the /helper/ layer. A third j tap turns /target/ off.

But this locks you out of repeated keypresses in the base layer, so I would set these up in the /nav/ layer instead. I think the mental overhead is still acceptable at this point, so long as you're ok with two-tap activation.

The karaml-friendly way would be to allow this:

/base/:
  <a-j>: [/target/, /target/]

The reason this doesn't work now is because setting a /layer/ in the second position automatically registers a {set_variable: { name: layer_name, value: 0} } map in the to_after_key_up nested dictionary. So whether you tap or hold, the layer gets switched off when the key is released. Bad oversight on my part. More bubblegum code can probably fix this.

TO (toggle off?) layer

  • TO(Layer) - activates layer and de-activates all other layers (except your default layer).
    This seems doable - store a list of all layers before creating the translated-mappings and with a special-event/pseudo function, add all the necessary set_variable events, e.g. to(layer_name).

Default Layer

  • DF(layer) - switches the default layer. The default layer is the always-active base layer that other layers stack on top of. ...

This one likely isn't possible without a rewrite (which I'd like to do someday)

Layer-Mod

  • LM(layer, mod) - Momentarily activates layer (like MO), but with modifier(s) mod active. Only supports layers 0-15. The modifiers this keycode accept are prefixed with MOD_, not KC_. These modifiers can be combined using bitwise OR, e.g. LM(_RAISE, MOD_LCTL | MOD_LALT).

I think the same thing can be achieved with a combination of sticky() and var() with relatively little mess? So maybe a new pseudo-function can achieve this, but I need to test it.

LT

LT(layer, kc) - momentarily activates layer when held, and sends kc when tapped. Only supports layers 0-15.

Not sure I understand what this one does, will read more later.

Better aliases for modifiers

g for command (gui) and a for option (alt) are ok, but h for shift and r for control look bad in the configuration. l for caps_lock isn't great either. I don't likem/m for left/right_command mainly because in Vim M is used for Meta as a modifier, and on Mac that's equivalent to the option keys.

The lower/upper-case system for left/right modifiers seemed like a good solution for keeping modifiers down to a single letter but it can be hard to distinguish them, especially o and O, and I've found myself wondering why some mapping wasn't triggering because I didn't notice this.

Needs improvement.

Can't chain multiple shell commands

e.g.

/base/:
  <gahr-8>: shell(open ~/.config/) + shell(open ~/Applications/)
  <gahr-8>: shell(mkdir ~/.qutebrowser/testing) + shell(open ~/.qutebrowser/)
  <gahr-8>: shell(open ~/.config/) + shnotify(hello, world)

The first of those commands opens the Applications folder but not .config, the second opens the .qutebrowser folder but doesn't create testing/, etc.No error messages in the Karabiner-Elements GUI Log.

The 'workaround' (which is what one would probably do anyway is the obvious, e.g.

<gahr-8>: shell(mkdir ~/.qutebrowser/testing && touch ~/.qutebrowser/testing/test.txt)

But it would be nice to compartmentalize the wrapped shell pseudo-funcs like shnotify(), open(), etc.

Potential fixes:

  • see if this has been addressed already in KE
  • when creating the keymap, check if there are multiple shell-based pseudo-funcs and chain them

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.