swhkd icon indicating copy to clipboard operation
swhkd copied to clipboard

Feature: one-off /temporary/single press mode

Open BlueDrink9 opened this issue 2 years ago • 8 comments

The mode system is excellent, but it is slightly different to sxhkd in that it it does not give easy one-off chords. For example, with sxhkd I do

super + e; t 
 kitty

to execute terminal. I do something similar for a bunch of other commands too, often with multiple options etc. With swhkd I would have to do

mode execute
t
 kitty && @escape

That's a fine workaround for a once-off, but becomes very frustrating to do for every chord I define.

This could be enhanced by allowing modes that do not persist (eg mode execute autoescape/nonpersist/temporary/onceoff), but instead automatically pop the stack after the next keystroke. (It would also be wonderful to be able to define a command to run when escaping up the stack in this way).

BlueDrink9 avatar Oct 15 '22 21:10 BlueDrink9

As a side note, I tried to understand the parsing system for the config but found it quite difficult. Is there a reason the project isn't using a grammar-based parser? Is it to avoid dependencies or is it lack of familiarity with CF grammars?

BlueDrink9 avatar Oct 15 '22 22:10 BlueDrink9

Thanks for the issue!

To answer your comment: I am not sure why it was done this way in the beginning, as I was not part of the team. I agree that the config parsing code is a bit difficult to follow, and it takes some time to get through.

I am planning to write a formal grammar for the config, but haven't taken the time to do it. Once this is done, writing the config parsing code using a separate library will be easier. Quite a few of them exist for Rust: pest and rust-peg seemed interesting, but a lot of alternatives also exist.

ajanon avatar Oct 17 '22 06:10 ajanon

In your previous comment (https://github.com/waycrate/swhkd/issues/67#issuecomment-1278747644) you also mentioned using skhd. Quickly looking through sxhkd, skhd and swhkd, it seems all three try to do something similar but each with a slightly different config syntax.

I wonder if some standardization could be achieved.

ajanon avatar Oct 17 '22 06:10 ajanon

I looked at my skhd config and realised it does modes well but not chords. Sxhkd does chords well, modes ok, but not modes and chords together. I don't see how standardising them will be helpful. You'd lose desirable syntax elements for the sake of compatibility

BlueDrink9 avatar Oct 19 '22 02:10 BlueDrink9

Ideally, we could have a single standardized config format for all three applications with all their features and maybe even a common parsing library. This may be hard to achieve, and as you said, maybe not that desirable.

ajanon avatar Oct 19 '22 08:10 ajanon

Replied in #168

BlueDrink9 avatar Oct 20 '22 09:10 BlueDrink9

@BlueDrink9 Would you mind taking a look at the newly implemented mode options?

ajanon avatar Dec 24 '22 08:12 ajanon

Will do, sorry I haven't gotten around to it yet (AoC still sucking through my time :sweat_smile:

BlueDrink9 avatar Dec 30 '22 07:12 BlueDrink9