Skip to content

Conversation

@wincent
Copy link

@wincent wincent commented Mar 8, 2014

This can be useful to distinguish between apps like Chrome and Chrome
Canary (which both report their name as "Google Chrome" but have bundle
identifiers com.google.Chrome and com.google.Chrome.canary
respectively).

This can be used in a .slate.js to do things like the following,
which is a layout that pushes Canary windows to the left half of the
screen and normal Chrome windows to the right half:

slate.layout('my-layout', {
  'Google Chrome': {
    operations: [function(window) {
      var app = window.app();
      if (app.bundleIdentifier() === 'com.google.Chrome.canary') {
        // code to push window left
      } else {
        // code to push window right
      }
    }],
    repeat: true,
  },
});

This can be useful to distinguish between apps like Chrome and Chrome
Canary (which both report their name as "Google Chrome" but have bundle
identifiers `com.google.Chrome` and `com.google.Chrome.canary`
respectively).

This can be used in a `.slate.js` to do things like the following,
which is a layout that pushes Canary windows to the left half of the
screen and normal Chrome windows to the right half:

    slate.layout('my-layout', {
      'Google Chrome': {
        operations: [function(window) {
          var app = window.app();
          if (app.bundleIdentifier() === 'com.google.Chrome.canary') {
            // code to push window left
          } else {
            // code to push window right
          }
        }],
        repeat: true,
      },
    });
wincent added a commit to wincent/wincent that referenced this pull request Mar 8, 2014
It turns out the simplest way to figure out the bundle identifier of a
given window's app is to run a patched version of Slate; here's the
patch and corresponding branch and pull request:

  https://github.com/wincent/slate/commit/e8de1a768ddd2d8188acfb6009
  https://github.com/wincent/slate/commits/bundle-identifiers
  jigish/slate#387

So that we don't break if we're not running a patched version, we fall
back to the old behavior if Slate doesn't have a `bundleIdentifier()`
method.

The layouts are pretty gnarly and dense at this point, so I'll ponder
and see if I can come up with a nice way of expressing these changes.

Signed-off-by: Wincent Colaiuta <[email protected]>
@sdegutis
Copy link

@wincent
Copy link
Author

wincent commented Jul 19, 2014

It was implemented in the pull request 4 months ago.

On Friday, July 18, 2014, Steven Degutis [email protected] wrote:

@jigish https://github.com/jigish @wincent https://github.com/wincent
When implementing this feature, this code may be of help:
https://github.com/sdegutis/hydra/blob/b20be10f649f4d1c2c7785a00b0602afec14c801/Hydra/API/application.m#L193-L194


Reply to this email directly or view it on GitHub
#387 (comment).

@sdegutis
Copy link

@wincent Oh. My mistake. Sorry for the noise.

@wincent
Copy link
Author

wincent commented Jun 7, 2021

Closing to clear out my open PRs list.

@wincent wincent closed this Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants