URL Commands
Some of LaunchBar’s internal functionality can be accessed via URL commands. They can be used in AppleScripts, Shell Scripts or search templates.
As of LaunchBar 5, the same functionality can be accessed much more conveniently using the corresponding AppleScript commands.
URL commands are URLs utilizing LaunchBar’s custom “x-launchbar” URL scheme. They can be used to display large text messages, to select items in LaunchBar, to run command line tools in background, to trigger commands from the Services menu, and more.
You can open such URLs using “open location” in AppleScripts, using the “open” command in Shell Scripts, or by creating search templates with this scheme.
AppleScript
open location "x-launchbar:large-type?string=Hello+World"
Command Line
open "x-launchbar:large-type?string=Hello+World"
Search Template
x-launchbar:large-type?string=*
Note: When using URL commands in search templates, the UTF-8 string encoding must be used.
Large Type Display
The large-type command can be used to display arbitrary strings in large type. Multiple lines can be separated with a backslash character.
Arguments
- string: the string that shall be displayed in large type.
- title: an optional title, displayed above the string.
- font-name: optional, allows to specify the PostScript name of the display font.
Examples
Selecting Items
The select command can be used to select arbitrary items in LaunchBar:
Running Unix commands in background
The execute command allows to create search templates that refer to local Unix Executables or Shell Scripts. In contrast to running these commands directly, the search template executes them in background so that no Terminal window opens to show their stdout.
For security reasons, the execute command only works in conjunction with search templates, it can’t be triggered from other applications.
Arguments
- path: the full path of the Unix command.
- argument: an optional argument. The value is considered to be a single argument, so any necessary quoting and escaping is applied automatically.
- arguments: an optional list of space separated arguments. In contrast to argument, the value is passed to the command “as is”, so any necessary quoting or escaping must be applied by the caller.
Example
x-launchbar:execute?path=/usr/local/bin/MyScript&argument=*
x-launchbar:execute?path=/usr/bin/open&arguments=-a+%22*%22
Performing calculations
The calculate command can be used to send arbitrary arithmetic expressions to LaunchBar. The result of the expression is then evaluated with LaunchBar’s built-in Calculator and displayed in large type.
See the Calculator chapter, section “Invoking Calculator from external applications” for details.
Hiding LaunchBar
The hide command can be used in AppleScripts to hide LaunchBar.
Example
open location "x-launchbar:hide"