Switchbar API


Switchbar は、設定済みのルールに従ってブラウザやメールクライアントでリンクを開くための URL ベースの API を提供します。

URL 形式

switchbar://open/<link>

対応するリンクの種類:

  • https://
  • http://
  • mailto:

リンクはパーセントエンコーディングせず、そのまま末尾に追加してください。

Switchbar は既存のルールとリンク設定を適用します。一致するルールがない場合は、リンクを開くアプリの選択を求めます。

使用例

ターミナル

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)

Choosy との互換性

Switchbar は Choosy の URL スキームにも対応しているため、既存のスクリプトや連携機能を変更せずに利用できます。

対応する URL プレフィックス:

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

適切なプレフィックスの末尾に、対象のリンクを追加してください。