Skip to content
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

Toggle additional layer when some layer activates #886

Open
lobre opened this issue Dec 6, 2024 · 1 comment
Open

Toggle additional layer when some layer activates #886

lobre opened this issue Dec 6, 2024 · 1 comment

Comments

@lobre
Copy link

lobre commented Dec 6, 2024

I have a navigation layer on space. There, I have navigation mappings for my window manager. But I would also like to have two variations that will change the behaviour of the d and f keys when the tab key is hit. And be able to go back and forth between the variations still by using tab.

Except for this subtle change of d/f, all the rest of the mappings are the same and I have plenty of them. I could define two variation layers nav_variation_one and nav_variation_two and swap between them when tab is hit. However, this would make me duplicate all the rest of the mappings except d/f for both layers. Here is an example:

[main]
space = overloadt(nav_variation_one, space, 150)

[nav_variation_one]
tab = swap(nav_variation_two)

# the only part that changes for this variation
d = S-tab
f = tab

# plenty of common mappings
q = M-1
w = M-2
e = M-3
...

[nav_variation_two]
tab = swap(nav_variation_one)

# the only part that changes for this variation
d = M-S-tab
f = M-tab

# plenty of common mappings
q = M-1
w = M-2
e = M-3
...

And here I am only talking about two variations but if I want more, I have a lot of duplication happening.

This is not convenient and this is one of the reasons why I hit the descriptor limit as raised in: #876.

So I was wondering if I could use layering with a common layer below and two variation layers on top of it. This way, variation layers would only define d/f mappings and the rest would traverse to the underlying common layer.

But for that, I would need to be able to directly toggle the first variation as soon as the common layer is activated. Let me give an example of how I imagine that:

[main]
space = overloadt(nav_common, space, 150)

[nav_common]
# at activation find a way to:
# toggle(nav_variation_one)

# plenty of common mappings
q = M-1
w = M-2
e = M-3
...

[nav_variation_one]
tab = swap(nav_variation_two)

d = S-tab
f = tab

[nav_variation_two]
tab = swap(nav_variation_one)

d = M-S-tab
f = M-tab

I read the manpage extensively but I don’t find an easy way to do this. If overload would take a macro after enabling the layer, I could do toggle(nav_variation_one) but that is not the case.

Is there a way to achieve this that I would have missed? Thanks.

@rvaiya
Copy link
Owner

rvaiya commented Dec 18, 2024

At the moment the best way to achieve this is to put common bindings in another file and then include them. You cannot simultaneously toggle two layers, though I am playing with some ideas that may accommodate this in the next version.

Personally, I would do something like this:

/etc/keyd/common-nav:

q = M-1
w = M-2
e = M-3

/etc/keyd/main.conf:

...
[nav_variation_one]
d = S-tab

include common-nav

[nav_variation_two]
d = M-S-tab

include common-nav

The advantage of this approach is that you can easily recycle nav bindings between files which correspond to different devices. I frequently do this with my ergonomic boards and find it quite useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants