al-ce / karaml Goto Github PK
View Code? Open in Web Editor NEWWrite and update your Karabiner-Elements config in YAML
License: MIT License
Write and update your Karabiner-Elements config in YAML
License: MIT License
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.
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)
(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.
/layer/
in the second positionTG(layer)
- toggles layer, activating it if it's inactive and vice versa
/layer/
in the first positionThe following can be achieved but in a hacky messy way or are not possible atm:
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.
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.
set_variable
events, e.g. to(layer_name)
.This one likely isn't possible without a rewrite (which I'd like to do someday)
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(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.
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.
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:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.