JonnyHaystack / i3-resurrect

Simple solution to saving and restoring i3 workspaces
GNU General Public License v3.0
378 stars 19 forks source link

Add a way to map from a window properties filter to a new set of swallow values #94

Open JonnyHaystack opened 4 years ago

JonnyHaystack commented 4 years ago

This would allow us to match a window that could have a dynamic title and set it up so that its placeholder will swallow any window matching a custom regex.

Actually there's a simple way to achieve this:

  1. Allow window_swallow_criteria to map using a window property filter just like window_command_mappings (#93)
  2. Implement regular expressions for window filters (including swallow criteria) (#92)
  3. Make it so the placeholder window uses the regex filters used for the swallow criteria as the values to swallow for those criteria

Sounds like the perfect solution to me. It should work so well that users don't even notice, and it doesn't add any extra confusing configuration to the config file.

To provide a somewhat similar example to #92 and #93, imagine this scenario:

This means that the window cannot be swallowed by title correctly unless the framerate happens to exactly match what it was when the workspace layout was saved.

Here is a configuration example that (with this new feature being implemented) would solve this:

{
  ...
  "window_swallow_criteria": {
    {
      "class": "^PCSX2$",
      "title": "^Kingdom Hearts [0-9]*FPS - PCSX2$",
      "swallows": ["class", "instance", "title"]
    }
  }
  ...
}

When saving the layout, the swallow criteria rule would match the game window and overwrite the title of the placeholder window with the regex that we used for the filter. This means that the placeholder window will now swallow any window that matches our regex, so the game window will be swallowed correctly regardless of the current framerate of the game.

Note: The class name and title regex in the example above were made up on the spot and in reality the regex could be much simpler. I just wanted to give an example that shows a glimpse of how precisely you could match windows.

aarobc commented 3 years ago

Seeing as this is scheduled for v2 yet there is not yet a v2 branch, are you accepting PRs for this feature?

This would be enormously useful.