Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support exclusions in regular expression #173

Closed
dominiklohmann opened this issue Jul 30, 2019 · 4 comments
Closed

Support exclusions in regular expression #173

dominiklohmann opened this issue Jul 30, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@dominiklohmann
Copy link
Collaborator

dominiklohmann commented Jul 30, 2019

Feature request

A common way to use regular expressions is to exclude matches. This can be done easily using regular expressions with negative-lookahead support, where ^(?!foo).*$ would match every line that does not begin with foo.

yabai currently does not support negative lookahead.

An alternative to supporting a more advanced regex syntax would be to allow inverting matches, e.g. by supporting [[!] app=<regex>] instead of [app=<regex>] filters, where the optional ! would invert the match.

@Kryan90
Copy link

Kryan90 commented Jul 31, 2019

I am also interested in a way to do this with yabai.

Chunkwm had a feature when defining a rule to add an "--except" flag which I used for a few rules.

Right now, I am doing this for Pycharm and it kind of works:

yabai -m rule --add app="PyCharm" manage=off
yabai -m rule --add app="PyCharm" title="^-PyCharm-.*" manage=on

Once I tile the main window, other spawned windows will float. But I have to manually tile the main window.
(I added -PyCharm- to the title of the main window using this plugin for pycharm: https://plugins.jetbrains.com/plugin/9681-custom-title/ )

@jmcvaughn
Copy link

jmcvaughn commented Aug 9, 2019

Either of these features would be great. For Microsoft Outlook I'm currently trying to send the main window to a particular desktop, tile the main and compose windows, and float the rest. Some experimentation suggests there isn't precedence (e.g. first/last matching rule applies) but perhaps I'm doing something wrong. An example set of rules:

## Float all windows by default
yabai -m rule --add label=outlook_float \
  app='Microsoft Outlook' \
  manage=off

## Send main window to Space 3
yabai -m rule --add label=outlookmain_s3 \
  app='Microsoft Outlook' \
  title='^(Inbox .+@.+$|Calendar$|People$|Tasks$|Notes$)' \
  space=3

## Tile main and email windows
yabai -m rule --add label=outlookmainemail_tile \
  app='Microsoft Outlook' \
  title='^.+@.+$' \
  manage=on

The results are inconsistent; restarting yabai will apply the second rule, but close and reopen the window and it'll follow the floating rule. It seems occasionally the second rule will be followed when restarting Outlook. Changing the order rules are defined in .yabairc doesn't make a difference. Invert/--except capability would allow the floating rules to be explicitly defined, e.g.:

yabai -m rule --except --add label=outlookother_float \
  app='Microsoft Outlook' \
  title='^(.+@.+$|Calendar$|People$|Tasks$|Notes$)' \
  manage=off

jmcvaughn pushed a commit to jmcvaughn/mac_setup that referenced this issue Aug 9, 2019
- Update yabai rules to open Outlook main window to Display 1 Space 3
  - Currently cannot get rules working to float all windows apart from
    main and compose. See koekeishiya/yabai#173 (comment)

- Switch Skype back to single-window mode (chats in main window)

- Float all chat app main windows and manually assign them to all desktops
@koekeishiya koekeishiya added the suggestion Request for new feature or some form of enhancement label Sep 3, 2019
@koekeishiya koekeishiya added the addressed on master; not released Fixed upstream, but not yet released label Mar 1, 2020
@koekeishiya
Copy link
Owner

koekeishiya commented Mar 1, 2020

Implemented on master with the following syntax: app[!]=<regex> and title[!]=<regex>, where [..] indicates that the token is optional. If != is specified instead of = to a non-regex parameter, the command will fail with an error indicating which key was invalid.

@koekeishiya koekeishiya added enhancement New feature or request and removed suggestion Request for new feature or some form of enhancement labels Mar 1, 2020
@koekeishiya
Copy link
Owner

@jmcvaughn

Some experimentation suggests there isn't precedence (e.g. first/last matching rule applies) but perhaps I'm doing something wrong.

Rules are applied in the order they were added. All rules that match will apply, not just the first one. If multiple rules specify a value for the same parameter, the latter rule will override that value, as it was applied last.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants