Skip to content

Commit

Permalink
Configuring/Window-Rules: callout that regexes need a full match (#909)
Browse files Browse the repository at this point in the history
* Update Window-Rules.md for regex full match clarification

* Add note for very general regexes

* Remove most unnecessary regex chars

* fix long line
  • Loading branch information
pynappo authored Dec 20, 2024
1 parent 2adbff5 commit 04ba521
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions pages/Configuring/Window-Rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ title: Window Rules
Window rules (both V1 and V2) are **case sensitive**. (e.g. `firefox`
`Firefox`)

As of Hyprland v0.46.0, regexes need to fully match the window values. For
example, in the case of `kitty`:

- `kitty`/`(kitty)`/`^(kitty)$`: Matches.
- `tty`: Used to match, now won't. Use `.*tty.*` to make it act like before, or
consider using a more specific regex.

{{< /callout >}}

## Window Rules V1
Expand All @@ -30,8 +37,8 @@ windowrule=RULE,WINDOW
### Examples

```ini
windowrule = float, ^(kitty)$
windowrule = move 0 0, title:^(Firefox)(.*)$
windowrule = float, kitty
windowrule = move 0 0, title:(Firefox)(.*)
```

## Window Rules V2
Expand All @@ -45,7 +52,7 @@ the `RULE` field is unchanged, but in the `WINDOW` field, you can put regexes
for multiple values like so:

```ini
windowrulev2 = float, class:(kitty), title:(kitty)
windowrulev2 = float, class:kitty, title:kitty
```

{{< callout type=info >}}
Expand All @@ -54,12 +61,12 @@ In the case of dynamic window titles such as browser windows, keep in mind how
powerful regex is.

For example, a window rule of:
`windowrule = opacity 0.3 override 0.3 override,title:(.*)(- Youtube)$` will match
`windowrule = opacity 0.3 override 0.3 override,title:(.*)(- Youtube)` will match
_any_ window that contains a string of "- Youtube" after any other text. This
could be multiple browser windows or other applications that contain the string
for any reason.

For the `windowrulev2 = float,class:(kitty),title:(kitty)` example, the
For the `windowrulev2 = float,class:kitty,title:kitty` example, the
`class:(kitty)` `WINDOW` field is what keeps the window rule specific to kitty
terminals.

Expand Down Expand Up @@ -219,8 +226,8 @@ hyprctl dispatch tagwindow +media title:Celluloid
Use `tag` rule to add a dynamic tag to a window:

```ini
windowrulev2 = tag +term, class:(footclient) # add dynamic tag `term*` to window footclient
windowrulev2 = tag term, class:(footclient) # toggle dynamic tag `term*` for window footclient
windowrulev2 = tag +term, class:footclient # add dynamic tag `term*` to window footclient
windowrulev2 = tag term, class:footclient # toggle dynamic tag `term*` for window footclient
windowrulev2 = tag +code, tag:cpp # add dynamic tag `code*` to window with tag `cpp`

windowrulev2 = opacity 0.8, tag:code # set opacity for window with tag `code` or `code*`
Expand All @@ -247,16 +254,16 @@ be cleared).
### Example Rules

```ini
windowrule = move 100 100, ^(kitty)$ # moves kitty to 100 100
windowrule = animation popin, ^(kitty)$ # sets the animation style for kitty
windowrule = noblur, ^(firefox)$ # disables blur for firefox
windowrule = move cursor -50% -50%, ^(kitty)$ # moves kitty to the center of the cursor
windowrule = move 100 100, kitty # moves kitty to 100 100
windowrule = animation popin, kitty # sets the animation style for kitty
windowrule = noblur, firefox # disables blur for firefox
windowrule = move cursor -50% -50%, kitty # moves kitty to the center of the cursor
windowrulev2 = bordercolor rgb(FF0000) rgb(880808), fullscreen:1 # set bordercolor to red if window is fullscreen
windowrulev2 = bordercolor rgb(00FF00), fullscreenstate:* 1 # set bordercolor to green if window's client fullscreen state is 1(maximize) (internal state can be anything)
windowrulev2 = bordercolor rgb(FFFF00), title:^(.*Hyprland.*)$ # set bordercolor to yellow when title contains Hyprland
windowrule = opacity 1.0 override 0.5 override 0.8 override, ^(kitty)$ # set opacity to 1.0 active, 0.5 inactive and 0.8 fullscreen for kitty
windowrule = rounding 10, ^(kitty)$ # set rounding to 10 for kitty
windowrulev2 = stayfocused, class:^(pinentry-) # fix pinentry losing focus
windowrulev2 = bordercolor rgb(FFFF00), title:.*Hyprland.* # set bordercolor to yellow when title contains Hyprland
windowrule = opacity 1.0 override 0.5 override 0.8 override, kitty # set opacity to 1.0 active, 0.5 inactive and 0.8 fullscreen for kitty
windowrule = rounding 10, kitty # set rounding to 10 for kitty
windowrulev2 = stayfocused, class:(pinentry-)(.*) # fix pinentry losing focus
```

### Notes
Expand All @@ -271,7 +278,7 @@ Rules will be processed from top to bottom, where the _last_ match will take
precedence. i.e.

```ini
windowrulev2 = opacity 0.8 0.8, class:^(kitty)$
windowrulev2 = opacity 0.8 0.8, class:kitty
windowrulev2 = opacity 0.5 0.5, floating:1
```

Expand All @@ -281,7 +288,7 @@ non-fullscreen floating windows will have `opacity 0.5`.

```ini
windowrulev2 = opacity 0.5 0.5,floating:1
windowrulev2 = opacity 0.8 0.8,class:^(kitty)$
windowrulev2 = opacity 0.8 0.8,class:kitty
```

Here, all kitty windows will have `opacity 0.8`, even if they are floating.
Expand All @@ -299,7 +306,7 @@ example, to set active and inactive opacity to 0.8, and make fullscreen windows
fully opaque regardless of other opacity rules:

```ini
windowrulev2 = opacity 0.8 override 0.8 override 1.0 override, ^(kitty)$
windowrulev2 = opacity 0.8 override 0.8 override 1.0 override, kitty
```

{{< /callout >}}
Expand Down

0 comments on commit 04ba521

Please sign in to comment.