jigish / slate

A window management application (replacement for Divvy/SizeUp/ShiftIt)
GNU General Public License v3.0
7.84k stars 509 forks source link

Feature Request: focus title_regex #505

Open MrBalonio opened 6 years ago

MrBalonio commented 6 years ago

Would it be possible to add focus title_regex? The feature would be useful when you have an application with multiple windows and you would like to focus directly to a specific window. Example: Terminal application with three windows open. Terminal windows can have in the title the following: ~/path/to/application ⌘2 The focus title_regex would focus the application first and then pass focus to the window matching the title Syntax could look something like this: bind i:${hyper} focus 'Terminal':TITLE_REGEX=.*⌘1

Thanks for your hard work in such an awesome tool.

JanLunge commented 6 years ago

you can do something like that in javascript already i use regex to position windows here is my sample

var regexmove = function (regex) {
  return {
    "operations": [function (windowObject) {
      var title = windowObject.title();
      if (title !== undefined && title.match(/^Developer\sTools\s-\s.+$/)) {
        //chrome dev window
        windowObject.doOperation(bookRightHalf);
      } else if (title !== undefined && title.match(/^Firebug\s-\s.+$/)) {
        //firefox dev window
        windowObject.doOperation(bookRightHalf);
      } else if (title !== undefined && title.match(/.+Google\sPlay\sMusic.+$/)) {
        //google play music
        windowObject.doOperation(bookFull);
      } else {
        //normal windows
        windowObject.doOperation(wideFull);
      }
    }],
    "ignore-fail": true,
    "repeat": true
  };
}