Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
elParaguayo committed May 1, 2024
1 parent f4117f8 commit 76807ef
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions libqtile/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,36 @@ class Match(_Match):
wid:
Match against the window ID. This is a unique ID given to each window.
Creating advanced rules
=======================
While the ``func`` parameter allows users to create more complex matches, this requires
a knowledge of qtile's internal objects. An alternative is to combine Match objects using
logical operators ``& ``(and), ``|`` (or), ``~`` (not) and ``^`` (xor).
For example, to create rule that matches all windows with a fixed aspect ratio except for
mpv windows, you would provide the following:
.. code::python
Match(func=lambda c: c.has_fixed_ratio()) & ~Match(wm_class="mpv")
It is also possible to use wrappers for ``Match`` objects if you do not want to use the
operators. The following wrappers are available:
- ``MatchAll(Match(...), ...)`` equivalent to "and" test. All matches must match.
- ``MatchAny(Match(...), ...)`` equivalent to "or" test. At least one match must match.
- ``MatchOnlyOne(Match(...), Match(...))`` equivalent to "xor". Only one match must match.
- ``InvertMatch(Match(...))`` equivalent to "not". Inverts the result of the match.
So, to recreate the above rule using the wrappers, you would write the following:
.. code::python
from libqtile.config import InvertMatch, Match, MatchAll
MatchAll(Match(func=lambda c: c.has_fixed_ratio()), InvertMatch(Match(wm_class="mpv)))
"""

def __init__(
Expand Down

0 comments on commit 76807ef

Please sign in to comment.