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

Support conditionality based on WM_NAME #2

Closed
4 tasks done
joshgoebel opened this issue Jun 4, 2022 · 6 comments · Fixed by #39
Closed
4 tasks done

Support conditionality based on WM_NAME #2

joshgoebel opened this issue Jun 4, 2022 · 6 comments · Fixed by #39
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@joshgoebel
Copy link
Owner

joshgoebel commented Jun 4, 2022

Support keymap and modmaps that are conditional on window name, not just class.


What needs to be done IMHO:

  • Support for wm_name added to KeyContext
  • Tests for wm_name conditions (at least in keymap basics)
  • Need test helper (for setting window context) for differentiating wm_class from wm_name (since we have a single window helper now
  • xorg likely needs to have a function that returns a dict with both name and class that KeyContext can consume

Related: tridactyl/tridactyl#4256

I dislike how this is speced in mooz/xkeysnail#129 :

define_keymap(lambda wm_class, device_name, wm_name: "Google Docs" in wm_name, {
     K("M-x"): K("M-slash")
})

This "just add another param to lambda" isn't great to read and is hard to deal with on the other side due to the varying number of arguments. (not to mention remembering the ordering, etc).


So I definitely think we should support this, it's just a question of what syntax to use... I'm perhaps imagining a wrapper function, but open to other suggestions.

# allow an array of conditions...
conditional([lambda wm_name: "Google Docs" in wm_name], 
   keymap("Google Docs", {
       K("M-x"): K("M-slash")
   })
)

Or even better a single context dict:

conditional(lambda ctx: "Google Docs" in ctx.wm_name , 
   keymap("Google Docs", {
       K("M-x"): K("M-slash")
   })
)

So instead of modmap and conditional_modmap there would only be a single modmap API that you would either wrap in a conditional or not...

This work has already been done now.

@joshgoebel
Copy link
Owner Author

Step 1: cae3135

@RedBearAK
Copy link
Contributor

The example with ctx seems the simplest, but what happened to the WM_CLASS? I’ve noticed that WM_NAME strings are often sort of generic, like “Document”. Would those examples be nested inside something referring to the WM_CLASS?

@joshgoebel
Copy link
Owner Author

Nothing, both would hang out on the context object and be referable by conditionals.

@joshgoebel joshgoebel added this to the 0.6.0 milestone Jun 11, 2022
@joshgoebel joshgoebel changed the title Support conditionality based on WM_NAME Support conditionality based on WM_NAME Jun 14, 2022
@joshgoebel
Copy link
Owner Author

I took care of this while working on the X error stuff since it was right there.

@joshgoebel joshgoebel modified the milestones: 0.6.0, 0.5.0 Jun 16, 2022
@joshgoebel joshgoebel self-assigned this Jun 17, 2022
@joshgoebel joshgoebel removed help welcome Help/contrib is esp welcome good first issue Good for newcomers labels Jun 19, 2022
@RedBearAK
Copy link
Contributor

@joshgoebel

I took care of this while working on the X error stuff since it was right there.

You closed this as completed, so is it actually ready to start messing with WM_NAME enhancements? I looked in config_api but only saw the WM_CLASS stuff as usual.

@joshgoebel
Copy link
Owner Author

Yes. KeyContext#wm_name

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

Successfully merging a pull request may close this issue.

2 participants