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

Feature request: add predefined targets for sticky and hidden #512

Closed
zappolowski opened this issue Oct 16, 2020 · 8 comments · May be fixed by #549
Closed

Feature request: add predefined targets for sticky and hidden #512

zappolowski opened this issue Oct 16, 2020 · 8 comments · May be fixed by #549
Labels
feature Feature request

Comments

@zappolowski
Copy link

zappolowski commented Oct 16, 2020

For matching windows for e.g. opacity-rule or shadow-exclude it might be handy to provide shortcuts for hidden and sticky (like the undocumented fullscreen) to avoid having to state several entries for each (as it's not known upfront on which entry within _NET_WM_STATE the entry in question ends up).

E.g. the example from ArchWiki

opacity-rule = [
  "0:_NET_WM_STATE@[0]:32a *= '_NET_WM_STATE_HIDDEN'",
  "0:_NET_WM_STATE@[1]:32a *= '_NET_WM_STATE_HIDDEN'",
  "0:_NET_WM_STATE@[2]:32a *= '_NET_WM_STATE_HIDDEN'",
  "0:_NET_WM_STATE@[3]:32a *= '_NET_WM_STATE_HIDDEN'",
  "0:_NET_WM_STATE@[4]:32a *= '_NET_WM_STATE_HIDDEN'",
];

could be written as

opacity-rule [
  "0:hidden",
];

instead.

A quickly made implementation can be found on my fork.

@tryone144
Copy link
Collaborator

I think the problem can be solved by performing the matching against all property values if no index is specified, i.e.

opacity-rule = [
  "0:_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'",
];

should fit your expectation of setting opacity to 0 for a window that has _NET_WM_STATE_HIDDEN somewhere in the _NET_WM_STATE atom. This behavior sounds more intuitive to me than the current "no index means first". Sample implementation can be found here.

The presets, like fullscreen provide access to the internal state of a window and are not just shortcuts for "does the _NET_WM_STATE atom contain _NET_WM_STATE_FULLSCREEN" like the ones proposed.
If we add shortcuts for specific window states, should we do so for all supported values? If so it might be better to access them like state = 'sticky' or state = 'hidden' similar to how window_type works currently.

@zappolowski
Copy link
Author

I agree with the approach of switching behavior to use the if-no-index-is-given-assume-anywhere as this is more general than my suggestion of special cases for hidden/sticky. Though I have to say, that reading them is something you have to get used to.

Introducing a new predicate like the suggested state = 'sticky' has the advantage of being easier to read (don't know how hard it is to implement).

The presets, like fullscreen provide access to the internal state of a window and are not just shortcuts for "does the _NET_WM_STATE atom contain _NET_WM_STATE_FULLSCREEN" like the ones proposed.

Additional checks (I cannot come up with examples at the moment) could be added to their respective functions if needed. Judging from the history of win_is_fullscreen this has been done in the past already and inspecting _NET_WM_STATE would serve as a starting point in this case.

@tryone144
Copy link
Collaborator

Introducing a new predicate like the suggested state = 'sticky' has the advantage of being easier to read (don't know how hard it is to implement).

Sadly the current matching implementation doesn't really lend itself to this kind of matching with custom functions (for fullscreen and focused). It is definitely easier to just add the simple presets like you already did.

@tryone144
Copy link
Collaborator

Introducing a new predicate like the suggested state = 'sticky' has the advantage of being easier to read (don't know how hard it is to implement).

Sadly the current matching implementation doesn't really lend itself to this kind of matching with custom functions (for fullscreen and focused). It is definitely easier to just add the simple presets like you already did.

I've made the _NET_WM_STATE property cached for all windows now. It can be accessed in the rules with i.e. wm_state = "hidden" for _NET_WM_STATE_HIDDEN. Keep in mind that using wm_state = "focused" or wm_state = "fullscreen" isn't the same as focused or fullscreen though.
The opacity example can be written as:

opacity-rule = [
  "0:wm_state = 'hidden'",
];

You can test it here.

@tryone144 tryone144 added the feature Feature request label Oct 25, 2020
@zappolowski
Copy link
Author

I've tested my settings with the new key predicates for hidden and sticky (kept the old ones for fullscreen) and everything works as intended. Thanks a lot for implementing this 👍

@tryone144
Copy link
Collaborator

#550 adds an updated syntax to match against any value in an atom-array.
The rules mentioned in the first post can now be simplified — without breaking existing configurations — to:

opacity-rule = [ "0:_NET_WM_STATE@[*]:32a *= 'HIDDEN'" ];

We have decided against adding the new wm_state predicate for now. See the discussion following #550 (comment) for more details.

@zappolowski
Copy link
Author

I've adjusted my configuration according to the new implementation for testing and it works as intended. I guess, the ticket can be closed now (as it's already merged to next)?

@tryone144
Copy link
Collaborator

Thanks for the feedback. I'm closing this now.

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

Successfully merging a pull request may close this issue.

2 participants