Skip to content

Make App.launch faster by changing the calling parameter #211

@txchen

Description

@txchen
  • Version: 2.6.1 (65)
  • macOS: 10.13.4

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:

let app = App.launch('iTerm')
  if (app) {
    app.focus()
  }

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 extra app.focus() call.

So, would it be okay to change the launch method (

+ (instancetype) launch:(NSString *)appName {
) to simply calling https://developer.apple.com/documentation/appkit/nsworkspace/1531434-launchapplication, or change the options:NSWorkspaceLaunchWithoutActivation to default, so that app.focus() can be avoided.

Or, maybe add a new method?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions