From e8de1a768ddd2d8188acfb6009e71fc8a5e3b4fa Mon Sep 17 00:00:00 2001 From: Wincent Colaiuta Date: Fri, 7 Mar 2014 21:49:31 -0800 Subject: [PATCH] Expose bundle identifier in app object 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, }, }); --- Slate/JSApplicationWrapper.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Slate/JSApplicationWrapper.m b/Slate/JSApplicationWrapper.m index 15c27a18..5219834a 100644 --- a/Slate/JSApplicationWrapper.m +++ b/Slate/JSApplicationWrapper.m @@ -68,6 +68,10 @@ - (pid_t)pid { return [app processIdentifier]; } +- (NSString *)bundleIdentifier { + return [app bundleIdentifier]; +} + - (NSString *)name { return [app localizedName]; } @@ -114,6 +118,7 @@ + (void)setJsMethods { if (jsawJsMethods == nil) { jsawJsMethods = @{ NSStringFromSelector(@selector(pid)): @"pid", + NSStringFromSelector(@selector(bundleIdentifier)): @"bundleIdentifier", NSStringFromSelector(@selector(name)): @"name", NSStringFromSelector(@selector(eachWindow:)): @"eachWindow", NSStringFromSelector(@selector(ewindow:)): @"ewindow",