切換列 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/

將目標連結附加至適當的前綴後方。