Does OS X provide an easy way to bind key combinations to commands which are typically run on the command line?

For example, is there some way to assign ⌘L as a global shortcut for /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine?

link|improve this question

67% accept rate
feedback

2 Answers

up vote 5 down vote accepted

Yes, you can do this with Applescript or Automator.

The way I've done things like this is to use Automator to create a Service that is available in all applications. A service can be made to run a bash/zsh/ruby/whatever script. Then you can bind a key combination to the service in the Keyboard pane of system preferences.

Near the end of this MacBreak podcast this procedure is shown in detail.

Edit: I just noticed you're not using Snow Leopard. I don't think creating a system-wide service is as easy with 10.5.8. I guess you can't upgrade since it's a Powerbook. You might want to look into FastScripts which allows you to assign keyboard shortcuts to applescripts (free to use for up to 10 keyboard shortcuts) and use the following Applescript:

do shell script "/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine"
link|improve this answer
feedback

FastScripts

The menu is automatically populated with files from ~/Library/Scripts/. Shortcuts for scripts in ~/Library/Scripts/Applications/SomeApp/ are enabled only when SomeApp is frontmost.

Other apps that can be used to assign shortcuts for running scripts

Creating an Automator service

  1. Open Automator and choose the Service template
  2. Add a Run Shell Script or Run AppleScript action
  3. Check that the values for "Service receives selected text in any application" are correct
  4. Paste the script and save
  5. Assign a shortcut in the Keyboard preference pane

ThisService

An application that can be used to make services where the service bundle either contains the original script or an alias to an external script.

link|improve this answer
Impressive list of tools. – Daniel Beck Mar 31 '11 at 16:57
open -a ScreenSaverEngine is even a tad shorter. – koiyu Apr 13 '11 at 20:13
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.