hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
21.25k stars 895 forks source link

Invert window rule selectors #7661

Open haasn opened 1 month ago

haasn commented 1 month ago

Description

It would sometimes be useful to be able to invert window rule selectors, e.g.

windowrulev2 = suppressevent focusactive, !onworkspace:special

(In this case implementing the desired feature of enabling focus_on_activate only on the special workspace)

Edit: As an aside, why are window rules so restricted? There are a lot of window properties available to hyprctl setprop but not to window rules, e.g. focusonactivate, which would also solve this problem.

haasn commented 1 month ago

Note: You can work around it using tags:

windowrulev2 = tag +nofocusactive, class:(.*)
windowrulev2 = tag -nofocusactive, onworkspace:special
windowrulev2 = suppressevent activatefocus, tag:nofocusactive

But I think it would be a useful baseline feature nonetheless

Edit: By the way, why it suppressevent not considered a dynamic rule? I don't see why it should only affect window creation.

haasn commented 1 month ago

In general, it would be useful to support arbitrary expressions, e.g. class:(firefox) && !title:(YouTube), but this would be a more involved change to implement.

vaxerski commented 1 month ago

By the way, why it suppressevent not considered a dynamic rule? I don't see why it should only affect window creation.

idk cuz I made it that way

haasn commented 1 month ago

Note to any future people hitting this limitation:

You can already invert regex-based expressions, by using a (?!) negative lookahead:

windowrulev2 = suppressevent activatefocus, class:^(?!dev\.zed\.Zed$)
prufaraSS commented 1 month ago

i'm currently using this workaround to make any steam windows float but not the main window: windowrulev2 = float, class:(team)$, title:^(?!Steam$).*$ (there appear to be two types of steam class: steam and Steam)

zukigay commented 3 weeks ago

i'm currently using this workaround to make any steam windows float but not the main window: windowrulev2 = float, class:(team)$, title:^(?!Steam$).*$ (there appear to be two types of steam class: steam and Steam)

I found this thread looking for how to do that cleanly, thanks so much.