Per sviluppatori

API di Switchbar

Switchbar dispone di un'API basata su URL. Apri un URL appositamente formattato e Switchbar entra subito in azione — inviando un link al browser o al client email giusto, oppure chiedendoti di sceglierne uno.

Come funziona

switchbar://open/<link>
  • Link web ed email

    Passa qualsiasi link https://, http:// o mailto:.

  • Valgono le tue regole

    Il link passa per le tue regole e impostazioni dei link, proprio come un clic. Se nessuna regola corrisponde, Switchbar ti chiede dove aprirlo.

  • Nessuna codifica

    Aggiungi il link così com’è dopo switchbar://open/, senza codificarlo.

Esempi

Terminal

# macOS
open "switchbar://open/https://example.com"
open "switchbar://open/mailto:hello@example.com"

# Windows
start "" "switchbar://open/https://example.com"

AppleScript

open location "switchbar://open/https://example.com"

JavaScript

window.location.href = "switchbar://open/https://example.com";

Swift

let url = URL(string: "switchbar://open/https://example.com")!
NSWorkspace.shared.open(url)

Compatibile con gli URL di Choosy

Switchbar apre anche i link dell’API di Choosy, quindi script e strumenti creati per Choosy funzionano senza modifiche.

x-choosy://open/
x-choosy://prompt.all/
x-choosy://prompt.running/
x-choosy://best.all/
x-choosy://best.running/