I just came from linux world (xfce4), where my keyboard workflow consisted of mapping

  • F9 to terminal app
  • f10 to firefox
  • f11 to emacs

Upon pressing, the corresponding app would a) get focused (raised) or b) started. I achieved that by using wmctrl.

Can I achieve this natively in Sierra or is there an app for that?

2 Answers 2


There's no direct way to map an Application launch to a key command, but it can be achieved without too much difficulty.

To break it down into its components, you need

  • A Service, which can be key-commanded

  • An Applescript, to contain the actual launch command

  • An Automator workflow, to contain the Applescript

  • The actual key-command.

It might sound hugely long-winded, but it's simpler than building your own .plist

  1. Launch Automator, from Applications

  2. Select New Document, then Service

  3. On the left, search 'applescript' & drag Run Applescript to the main panel enter image description here
  4. Replace (* Your script goes here *) with tell Application "Terminal" to activate
    Using activate will launch the App if it is not running, or bring it to the front if it already is. [subsequent Services you generate will use each of your desired Apps in this line]
  5. Click at the top where it says 'Untitled' & give it a suitable name. The destination will be already correct for Services.
  6. Hit Cmd ⌘ S to Save.
    At the moment I'm seeing a new behaviour I've not noticed before, under 10.11.6 - Saving isn't automatically installing the service. Closing the Workflow window, then re-opening from File menu > Recent then gives the option to install it. ymmv.
  7. Go to System Prefs > Keyboard > Shortcuts > Services & find your new Automator Service [probably down towards the bottom of the list under General.
    Make sure there's a checkmark to the left of it, then click none/add shortcut, to the right & add your F-Key
    Make sure your pref in System Prefs > Keyboard > Keyboard is set to use all F1, F2 etc as standard function keys - otherwise you'll have to use Fn/F-key instead.

enter image description here

Rinse & repeat for your other required Applications.

After comments:
Running Services in this way may require Automator to be checked in System Prefs > Security & Privacy > Privacy > Accessibility

  • Thanks for very detailed answer. I managed to write the scripts and they work in the Automator upon pressing the play button. However shortcuts seems to do nothing (There is a checkmark in the shortcuts window. cmdF9 doesnt work either, fn keys are F9 works without fn). Can I provide more info to so you can help me debug this?
    – redacted
    Dec 24, 2016 at 14:26
  • So they definitely appear as Services in the shortcuts panel - yet don't activate using the key command? I'd test using some command that couldn't possibly be duplicated elsewhere or confused with anything else; something like cmd/ctrl/opt/shift/z to eliminate either possibility.
    – Tetsujin
    Dec 24, 2016 at 14:31
  • the issue was probably that Automator was not ticked in the System preferences > Security & privacy > Accessibility. So I got that one working. However I got 2 more issues. a) there is slight delay (±400ms?) and more importantly b) emacs catches the f[8,9,10] calls so it doesnt work when it is active window. Do you have any tips on that, or should I ask emacs folks?
    – redacted
    Dec 25, 2016 at 21:40
  • The delay might just be how long it takes a key command to find automator, find the command, activate, etc etc. Not really sure as I've never really timed one to see. Re emacs, it's not something I've ever used, so I'd think you may be better asking them, or post as a separate question in SE.
    – Tetsujin
    Dec 30, 2016 at 12:53

EDIT: Found hammerspoon and it works like a charm + opens many more doors. Example config here

Tetsujins answer is great and is probably the native way. Just for the record I eventually found an app http://www.apptivateapp.com/ (free at the time of writing) which does exactly what I wanted in few clicks without any hassle.

It also doesnt suffer from emacs capturing keystrokes and there is close to zero latency.

Still AppleScript loooks like powerful tool worth knowing.

  • Glad you found something to help. :)
    – Tetsujin
    Dec 30, 2016 at 12:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .