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

Be able to map key -> action pairs using a template inside of gen_keybindings #22

Closed
ghost opened this issue Aug 10, 2020 · 7 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Aug 10, 2020


name: Dynamic Keymap
about: Be able to give the gen_keybindings macro a vector of keys to iterate over and format each key into a general keymap template such as M-A-{}.
title: Dynamic Keymap
labels: enhancement


Is your feature request related to a problem? Please describe.
I want to be able to give a vector of keys to format into a general key binding.

Describe the solution you'd like
Either an extension of the gen_keybindings macro, for example a forall_vec option, or another macro that implements this for general use
Describe alternatives you've considered
I've only considered an extension of the macro such as an optional forall_vec option, or an entirely new macro for this purpose.

Edit (sminez):

As discussed in the comments below, this is more about taking key value pairs and mapping them within a template a la sxhkd. A full implementation like sxhkd is probably beyond the scope of this initial request as that involves forming the cross product of multiple expansions and also generating method / key names it seems. For this, the following example should be sufficient:

ctrl + super + {h,j,k,l} 
    bspc monitor -f {west,south,north,east}

something along the lines of the following is likely what we'll end up with (not valid methods in penrose but using the same example for clarity):

        map [ h, j, k, l ] in {
            "M-C-{}" => internal, move_focus [ west, south, north, east ];
        }
@ghost ghost added the enhancement New feature or request label Aug 10, 2020
@sminez
Copy link
Owner

sminez commented Aug 10, 2020

Hi @roelycooly , can you fill in the details outlined in the issue template for this? I thought I'd set that up to auto-fill when creating a new issue but maybe not.

@ghost
Copy link
Author

ghost commented Aug 10, 2020

Alright, lol sorry I saw that and thought it was some weird filler thing I was supposed to remove that github put. I changed the comment and will do so with my other enhancement request

@sminez
Copy link
Owner

sminez commented Aug 18, 2020

Hi @roelycooly , are you able to give some concrete examples of how you are wanting to use this? I had a go at hacking something together the other day and I wasn't able to come up with anything that felt general purpose enough to warrent being part of the macro. You iterate over &str / String elements in the vector and format them into the keybindings, and then all you can really do is use the index as a Selector in a method that takes one (not all methods do), or pass that key to a function / closure that works out the binding (which defeats the point of having a simple iteration)

@ghost
Copy link
Author

ghost commented Aug 23, 2020

An example from something like sxhkd would be:

XF86Audio{Raise,Lower}Volume 
    pulsemixer --change-volume {+,-}5
XF86Audio{Next,Prev} 
    playerctl {next,previous}
XF86MonBrightness{Up,Down} 
    brightnessctl s 10%{+,-}

Or:

ctrl + super + {h,j,k,l} 
    bspc monitor -f {west,south,north,east}

This is pretty much the functionality that I would like implemented.

@sminez
Copy link
Owner

sminez commented Aug 26, 2020

Ah ok, that makes more sense: you're not formatting the keys themselves into the binding, you want to map key/value pairs in a template. I'll update the issue title and description and hopefully should be able to get on this soon. I can see why you want it!

@sminez sminez changed the title Iterate through a vector of keys to format into a keymap Be able to map key -> action pairs using a template inside of gen_keybindings Aug 26, 2020
@sminez sminez self-assigned this Aug 26, 2020
@ghost
Copy link
Author

ghost commented Aug 28, 2020

Ya sorry, English is my first language and yet I can never put my words together properly lol, but yeah a template is what I was trying to say. Anyways I hope it wouldn't be too much trouble implementing it and thank you for updating my comment.

sminez added a commit that referenced this issue Sep 19, 2020
improved keybinding generation for issue #22
@sminez
Copy link
Owner

sminez commented Sep 19, 2020

#68 provides an implementation sufficient for the simple given in the edited issue description. A full implementation of sxhkd functionality is going to be significantly more work to achieve it seems. For now I'm going to close this issue but I'll keep tinkering away with the keybinding generation macro over time and hopefully should be able to extend things further at a later date.

@sminez sminez closed this as completed Sep 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant