Pour les développeurs

API de Switchbar

Switchbar dispose d’une API basée sur les URL. Ouvrez une URL spécialement formatée et Switchbar entre en action — en envoyant un lien vers le bon navigateur ou client mail, ou en vous invitant à en choisir un.

Fonctionnement

switchbar://open/<link>
  • Liens web et e-mail

    Transmettez n’importe quel lien https://, http:// ou mailto:.

  • Vos règles s’appliquent

    Le lien passe par vos règles et vos réglages de liens, comme un clic. Si aucune règle ne correspond, Switchbar vous demande où l’ouvrir.

  • Aucun encodage

    Ajoutez le lien tel quel après switchbar://open/, sans l’encoder.

Exemples

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)

Compatible avec les URL Choosy

Switchbar ouvre aussi les liens de l’API Choosy : les scripts et outils conçus pour Choosy fonctionnent sans modification.

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