Browse the docs

Coming from LaunchBar

How a LaunchBar action becomes a macro with a palette keyword, which parts of LaunchBar's JavaScript API Switchboard provides, and what stays behind.

A LaunchBar action is a folder, Name.lbaction, holding one script and a property list that says what argument it takes. Import turns each one into a macro you run from the palette by typing a keyword and the argument.

Choose File › Import… and then LaunchBar actions on this Mac, or choose an .lbaction (or a folder of them) from Choose a File…. From a terminal: switchboard import --launchbar [path] (see switchboard import).

What an action becomes #

LaunchBarSwitchboard
The actionOne macro, named after the action. A folder of actions imports as one group named after the folder.
Its abbreviationA palette keyword: the initials of the name (Open Pull Request is opr), or the whole name when it is one word or the initials clash. LaunchBar keeps your own abbreviations in its preferences, where Switchboard can't read them: type the keyword you use in the review's Keyword column before you import (or change it later in the Inspector's Palette section).
Accepted argument: textA text input; the palette passes what you type after the keyword. Required if the action says so.
Accepted argument: filesA file input (one path per line)
No argumentNo input
A shell scriptA Run shell script step run with the shell on its first line; the argument is $1
A Python scriptA python step; the argument is sys.argv[1]
An AppleScriptAn appleScript step; handle_string and open handlers are called with the argument
Ruby, Perl, PHP, SwiftA shell step that runs the script with its first-line interpreter
A JavaScript scriptA Run JXA script step with LaunchBar's API in front of it (below)
An action that returns itemsA list you pick from. A row with a url opens it, a path opens the file, an action runs that function (or another script in the action) with its actionArgument, and children open a second list.
Runs in the backgroundThe macro may run more than once at a time
PreferencesKept in Preferences.json under Application Support/Switchboard/LaunchBar. Keys that look like credentials (token, key, password) are kept in the Keychain instead: the review gives the command that stores one.
Live feedback, suggestions, the x-launchbar URLNot imported; the review says so
Hotkeys, Instant Send, the indexStay in LaunchBar

Nothing is switched on until you choose to take over. Keep LaunchBar's own shortcut on its usual key, and Switchboard's palette on its own.

JavaScript actions #

Most public actions are JavaScript. Switchboard puts a copy of LaunchBar's API in front of the script, so these keep working. A script that calls something not in this table imports switched off, and the review names the call.

MemberStatusNote
LaunchBar.openURLWorksopen -b/-a for the app argument
LaunchBar.pasteWorkssets the clipboard, then presses Command-V (needs Accessibility)
LaunchBar.setClipboardStringWorks
LaunchBar.getClipboardStringWorks
LaunchBar.alertWorksa dialog with up to three buttons; returns the button's index
LaunchBar.displayNotificationWorks
LaunchBar.displayInLargeTypeWorksa HUD once the script ends
LaunchBar.executeWorks
LaunchBar.executeAppleScriptWorks
LaunchBar.formatDateWorksdateStyle, timeStyle and relativeDateFormatting
LaunchBar.logWorks
LaunchBar.hideWorksdoes nothing: there is no LaunchBar window to hide
LaunchBar.currentLocaleWorks
LaunchBar.optionsWorksno modifier key is ever held when a palette runs a macro
HTTP.getWorksthrough curl
HTTP.getJSONWorksthrough curl
HTTP.postWorksthrough curl
HTTP.postJSONWorksthrough curl
File.readTextWorks
File.readJSONWorks
File.writeTextWorks
File.writeJSONWorks
File.existsWorks
File.isDirectoryWorks
File.createDirectoryWorks
File.fileURLForPathWorks
File.pathForFileURLWorks
Action.pathWorksthe copy of the action kept in the macro's assets
Action.supportPathWorksApplication Support/Switchboard/LaunchBar/<bundle id>
Action.versionWorksthe bundle's CFBundleVersion
Action.cachePathWorksCaches/Switchboard/LaunchBar/<bundle id>
Action.preferencesWorksPreferences.json in the support folder; secret-looking keys in the Keychain
LaunchBar.performActionNot providedruns another LaunchBar action
LaunchBar.performServiceNot providedruns a macOS Service
LaunchBar.openCommandLineNot providedopens LaunchBar's own command line
LaunchBar.setInputNot providedputs text in LaunchBar's input field
LaunchBar.setOutputNot provided
LaunchBar.activateNot provided
LaunchBar.hideBezelNot provided
LaunchBar.showDialogNot provided
HTTP.loadRequestNot providedasynchronous requests
HTTP.createRequestNot providedasynchronous requests
File.readPlistNot provided
File.writePlistNot provided

A LaunchBar window isn't there, so LaunchBar.options always reads every modifier key as up, and LaunchBar.displayInLargeType shows a HUD when the script ends. LaunchBar.paste presses Command-V in the app that is in front, which needs Accessibility. HTTP calls go through curl, and the review lists the hosts a script talks to.

What comes in marked #

An AppleScript that returns records can't become a list, because osascript prints records as plain text; the macro shows the text. A script that is a compiled program, or an interpreter that isn't installed, imports off with the reason.