BTTを使ってタッチバーからSidecarを起動するための手引きがなかったので、個人的なメモも兼ねたまとめです。
動作環境
macOS Big Sur 11.6.1(Locale: Japan)
Better Touch Tool 3.3.89
設定項目
タッチバートリガー設定
Select Trigger
-> タッチバーボタン
トリガーの割り当て設定
Controlling Other Applications
-> Apple Scriptを実行する(ブロック)
スクリプトコードのペイン(以下画像参照)に下記コードを入力
スクリプト引用
satokaz. (2021). AppleScript で Sidecar の接続/接続解除をトグルする #17. https://github.com/satokaz/hitorigoto/issues/17.
tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.sidecar"
get the name of every anchor of pane id "com.apple.preference.sidecar"
delay 1
tell application "System Events"
set target_button to a reference to (first button whose name is "接続解除") of (window "Sidecar" of application process "システム環境設定")
if target_button exists then
click target_button
else
click menu button "デバイスを選択" of window "Sidecar" of application process "システム環境設定"
count menu items of menu of menu button "デバイスを選択" of window "Sidecar" of application process "システム環境設定"
select item 1 of menu button "デバイスを選択" of window "Sidecar" of application process "システム環境設定"
key code 125
key code 76
end if
end tell
quit
end tell
その他
satokaz(2021)でも触れられている通り、上記のAppleScriptはJP-Locale用なので、EN-Localeを設定されている方は、rauls4. (2020). Toggle-Sidecar-Automator-Action. https://github.com/rauls4/Toggle-Sidecar-Automator-Workflow. のコードを参照のこと。