Question

I am trying to make a keyboard shortcut to launch terminal in OS X Mountain Lion.

After some research I found out that I can use Automator to achieve this:

http://mac.tutsplus.com/tutorials/tips-shortcuts/how-to-launch-any-app-with-a-keyboard-shortcut/

It works, but I noticed that whenever I launch a terminal using this method, a process called WorkFlowServiceRunner starts and never terminates. To make matters worse when I launch more terminals (or launch different applications using shortcuts, again, through Automator) multiple WorkFlowServiceRunner processes start and quickly eat up the memory.

I've also tried writing my own applescripts but the problem does not go away. This clearly looks like a memory leak. Is this a bug in OS X Automator? Is there a way to write an applescript so that the WorkFlowServiceRunner terminates after doing its job (e.g. launch a terminal)? Automator seems to be the most "native" way of getting this done and I do not want to use any 3rd party apps.

Was it helpful?

Solution

I have noticed this from time to time.

One way around it would be to make your own service apps with a Cocoa-AppleScript Applet.

It is not very hard to do. And I will try and guide you through it. It should only take you a couple of minutes.

Step 1.

Open your Application Applescript Editor. And go to the "File" Menu -> "New from Template" -> Cocoa-AppleScript Applet.app

enter image description here

Step 2,

Paste this code into the new documents.

property NSWorkspace : class "NSWorkspace"

tell current application's NSApp to setServicesProvider_(me)
NSUpdateDynamicServices()

my runAService()
    on runAService()

            NSWorkspace's sharedWorkspace()'s launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier_("com.apple.Terminal", current application's NSWorkspaceLaunchDefault, missing value, missing value)

        tell me to quit
    end runAService

Step 3,

Compile
(click this to compile)

enter image description here

and Save the app.

*Make sure the show startup screen is unchecked in the Save dialogue.

Giving the app a name like LaunchTerminal.app

Step 4,

Click the "Bundle Contents" button on the top right hand side of the document.

This will open the applications contents view.

enter image description here

Click the Action button and then "Reveal in finder" sub menu.

enter image description here

step 5,

In the contents folder that opens in the finder you will see a file name "info.plist"

Open Terminal.app and type and run this code using the path to this file:

BUT make sure you do not include the ".plist" part of the name when entering it in Terminal.app

 /usr/bin/defaults write /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info  NSServices -array-add '{NSMenuItem={default="Launch Terminal";}; NSMessage="runAService"; NSSendTypes=();}'

( You can drag n drop the file into terminal to get the posix path string ) The path part looks like this: /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info

This code should add an array to the plist file which is part of the apps way of broadcasting it has a service.

The plist file Opened in a plist editor app

step 6,

Compile and Save the App again.

Just to make sure it picks up the changes. ( I found I had to do this even though I should not have to)

step 7,

Double click the app to run it for the first time.

The App will quit straight away. But the first run should have broadcast that it has a service that should be registered with the system

step 8,

Open system Preferences and go to Services -> General (section)

And you will see the "Launch Terminal" service.

Set up your short cut as normal.

Hope this helps..

UPDATE :

I noticed that the tell application "Terminal" to activate. Would not open my default Window groups if I had closed them all and quit Terminal before. The normal behaviour if I have done this is for my default window group to open. ( I have two Tabs open at startup each cd'd to a different path).

So I have change the open application to a cocoa way of doing it.

A do shell script with open the/application/path/. will work also.

OTHER TIPS

Try using Butler or QuicKeys. They both have endless "Trial periods."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top