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 #
| LaunchBar | Switchboard |
|---|---|
| The action | One macro, named after the action. A folder of actions imports as one group named after the folder. |
| Its abbreviation | A 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: text | A text input; the palette passes what you type after the keyword. Required if the action says so. |
| Accepted argument: files | A file input (one path per line) |
| No argument | No input |
| A shell script | A Run shell script step run with the shell on its first line; the argument is $1 |
| A Python script | A python step; the argument is sys.argv[1] |
| An AppleScript | An appleScript step; handle_string and open handlers are called with the argument |
| Ruby, Perl, PHP, Swift | A shell step that runs the script with its first-line interpreter |
| A JavaScript script | A Run JXA script step with LaunchBar's API in front of it (below) |
| An action that returns items | A 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 background | The macro may run more than once at a time |
| Preferences | Kept 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 URL | Not imported; the review says so |
| Hotkeys, Instant Send, the index | Stay 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.
| Member | Status | Note |
|---|---|---|
| LaunchBar.openURL | Works | open -b/-a for the app argument |
| LaunchBar.paste | Works | sets the clipboard, then presses Command-V (needs Accessibility) |
| LaunchBar.setClipboardString | Works | |
| LaunchBar.getClipboardString | Works | |
| LaunchBar.alert | Works | a dialog with up to three buttons; returns the button's index |
| LaunchBar.displayNotification | Works | |
| LaunchBar.displayInLargeType | Works | a HUD once the script ends |
| LaunchBar.execute | Works | |
| LaunchBar.executeAppleScript | Works | |
| LaunchBar.formatDate | Works | dateStyle, timeStyle and relativeDateFormatting |
| LaunchBar.log | Works | |
| LaunchBar.hide | Works | does nothing: there is no LaunchBar window to hide |
| LaunchBar.currentLocale | Works | |
| LaunchBar.options | Works | no modifier key is ever held when a palette runs a macro |
| HTTP.get | Works | through curl |
| HTTP.getJSON | Works | through curl |
| HTTP.post | Works | through curl |
| HTTP.postJSON | Works | through curl |
| File.readText | Works | |
| File.readJSON | Works | |
| File.writeText | Works | |
| File.writeJSON | Works | |
| File.exists | Works | |
| File.isDirectory | Works | |
| File.createDirectory | Works | |
| File.fileURLForPath | Works | |
| File.pathForFileURL | Works | |
| Action.path | Works | the copy of the action kept in the macro's assets |
| Action.supportPath | Works | Application Support/Switchboard/LaunchBar/<bundle id> |
| Action.version | Works | the bundle's CFBundleVersion |
| Action.cachePath | Works | Caches/Switchboard/LaunchBar/<bundle id> |
| Action.preferences | Works | Preferences.json in the support folder; secret-looking keys in the Keychain |
| LaunchBar.performAction | Not provided | runs another LaunchBar action |
| LaunchBar.performService | Not provided | runs a macOS Service |
| LaunchBar.openCommandLine | Not provided | opens LaunchBar's own command line |
| LaunchBar.setInput | Not provided | puts text in LaunchBar's input field |
| LaunchBar.setOutput | Not provided | |
| LaunchBar.activate | Not provided | |
| LaunchBar.hideBezel | Not provided | |
| LaunchBar.showDialog | Not provided | |
| HTTP.loadRequest | Not provided | asynchronous requests |
| HTTP.createRequest | Not provided | asynchronous requests |
| File.readPlist | Not provided | |
| File.writePlist | Not 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.