-
Notifications
You must be signed in to change notification settings - Fork 128
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
Make App.launch faster by changing the calling parameter #211
Comments
https://developer.apple.com/documentation/appkit/nsworkspace/1531434-launchapplication returns boolean, so App.launch(name) cannot use this because it will break scripts. How about add a new API like: App.launchAndShow(appName) |
Right! I think we can just add an options object as an additional argument for the |
I tried to make this change:
And I can confirm that with this change, opened App can show faster (about same speed of Thor, which uses |
PR created: #212 |
FYI, my related script for toggling apps: function toggleApp (appName, bundleName) {
const foremostApp = App.focused()
if (foremostApp && foremostApp.bundleIdentifier() === bundleName) {
foremostApp.hide()
return
}
App.launch(appName, { focus: true })
}
Key.on('1', ['alt'], () => toggleApp('iTerm', 'com.googlecode.iterm2'))
Key.on('1', ['alt', 'shift'], () => toggleApp('Wunderlist', 'com.wunderkinder.wunderlistdesktop'))
Key.on('2', ['alt'], () => toggleApp('Google Chrome', 'com.google.Chrome'))
Key.on('2', ['alt', 'shift'], () => toggleApp('Safari', 'com.apple.Safari'))
Key.on('3', ['alt'], () => toggleApp('Visual Studio Code', 'com.microsoft.VSCode'))
Key.on('3', ['alt', 'shift'], () => toggleApp('Visual Studio Code', 'com.microsoft.VSCode')) |
Implemented in #212. |
I am currently using this app to toggle my apps: https://github.com/gbammc/Thor/
It's toggle code is simple: https://github.com/gbammc/Thor/blob/4f86a1768d33f7dbaf61182e2f10179a6166ec6a/Thor/ShortcutMonitor.swift#L17-L23
Now if I want to do the same with phoenix, after I call App.launch(name), I need to make another call to let the app focus, like this:
Per my feeling (because I have not a good way to measure), toggling with Thor is faster than using Phoenix script. I think it is due to they are calling different API. The difference might come from
NSString *appPath = [sharedWorkspace fullPathForApplication:appName];
or the extraapp.focus()
call.So, would it be okay to change the launch method (
phoenix/Phoenix/PHApp.m
Line 44 in f02761e
https://developer.apple.com/documentation/appkit/nsworkspace/1531434-launchapplication
, or change theoptions:NSWorkspaceLaunchWithoutActivation
to default, so thatapp.focus()
can be avoided.Or, maybe add a new method?
The text was updated successfully, but these errors were encountered: