WayfireWM / wayfire

A modular and extensible wayland compositor
https://wayfire.org/
MIT License
2.36k stars 175 forks source link

[window-rules] assign_workspace doesn't work with other rules #1097

Open travankor opened 3 years ago

travankor commented 3 years ago

Describe the bug Assign_workspace will not work if you have another rule like maximize.

To Reproduce Steps to reproduce the behavior:

  1. Enable window-rules plugin

  2. Add config

    rule = on created if app_id is "app" then assign_workspace 0 1
    rule_2 = on created if app_id is "app" then maximize
  3. assign_workspace doesn't work

Expected behavior Assign_workspace works with other rules

Wayfire version 0.7.0

flexibeast commented 10 months ago

What i'm finding on 0.8.0 (and, if i remember correctly, 0.7.5 as well), is that there's not necessarily any connection between the use of assign_workspace and the use of other rules. An excerpt from my wayfire.ini:

[window-rules]

## Placement.

place_firefox = on created if title contains "Firefox" then assign_workspace 0 0
# Doesn't work, but app_id of emacsclient unavailable
#rule_3 = on created if app_id contains "Emacs" then assign_workspace 1 0
place_emacs = on created if title contains "Emacs" then assign_workspace 1 0
# Doesn't work
#rule_5 = on created if app_id contains "kitty" then assign_workspace 0 1
# Doesn't work
#rule_6 = on created if title contains "kitty" then assign_workspace 0 1
place_gimp = on created if app_id contains "Gimp" then assign_workspace 1 1
place_inkscape = on created if app_id contains "Inkscape" then assign_workspace 1 1
# Doesn't work
#rule_11 = on created if app_id contains "KeePassXC" then assign_workspace 1 2
# Doesn't work
#rule_12 = on created if title contains "KeePassXC" then assign_workspace 1 2

## Sizing.
maximize_firefox = on created if title contains "Firefox" then maximize
maximize_emacs = on created if title contains "Emacs" then maximize
maximize_kitty = on created if title contains "kitty" then maximize
# Don't use app_id in order to avoid maximising transients.
maximize_gimp = on created if title contains "GNU Image Manipulation Program" then maximize
maximize_inkscape = on created if app_id contains "Inkscape" then maximize
maximize_keepassxc = on created if title contains "KeePassXC" then maximize
maximize_wireshark = on created if app_id contains "Wireshark" then maximize
maximize_zathura = on created if app_id contains "zathura" then maximize

More generally, is there any way of getting the app_id without running a program from a terminal with WAYLAND_DEBUG=1, apart from (i assume, in >0.8.0) using the IPC system, which i've not had the space to explore yet?

ammen99 commented 10 months ago

You can try using the foreign-toplevel example from wlroots, it lists open toplevels and their attributes.

flexibeast commented 10 months ago

You can try using the foreign-toplevel example from wlroots, it lists open toplevels and their attributes.

That worked, thanks! i've also found lswt; i've added a section on the 'Tips & Tricks' page about both approaches.

flexibeast commented 10 months ago

So, with lswt now at my disposal, having enabled the foreign-toplevel plugin, i tested the placement rules listed in this comment. And .... they all started working (in general - caveat below), including in the presence of maximize rules.

It occurred to me that i should check what happened when i disabled the foreign-toplevel plugin. And the rules stopped working.

This makes sense to me (at least given my very limited understanding of Wayland 🙂 ). However, this dependency isn't listed in the relevant section of the 'Configuration' page. Is this behaviour actually intended? Or should window-rules work even without the foreign-toplevel plugin enabled?

Additionally, even with the foreign-toplevel plugin enabled, the rules don't work at startup. Might this be due to the window-rules plugin getting loaded before the foreign-toplevel plugin?

ammen99 commented 10 months ago

Hmm, foreign-toplevel should have no influence here. Maybe you are experiencing some sort of race condition, and the loading of foreign-toplevel simply changes the ordering of certain instructions.