実装の裏側(プラグインが担当):
HKCU\Software\Microsoft\Windows\CurrentVersion\Run にアプリパスを登録。~/Library/LaunchAgents/ に plist を配置)。~/.config/autostart/*.desktop に .desktop ファイルを配置)。起動引数(任意): プラグインの Builder で .args([...]) を指定できる。自動起動時に「トレイのみで起動」など振る舞いを変えたい場合は、ここで引数(例: --minimized)を渡し、アプリ起動時に解釈する。
flowchart TB
subgraph プラットフォーム別の実体
W[Windows: レジストリ Run]
M[macOS: LaunchAgents]
L[Linux: autostart .desktop]
end
P[tauri-plugin-autostart] --> W
P --> M
P --> L
U[ユーザー: enable/disable] --> P
tauri-plugin-autostart を依存に追加。tauri::Builder に .plugin(tauri_plugin_autostart::init(...)) を登録。必要なら .args([...]) で起動引数を指定。tauri.conf.json の plugins や capability を要求する場合は、ドキュメントに従い permission を追加。@tauri-apps/plugin-autostart の enable / disable / isEnabled を呼ぶ。Tauri コマンド経由でも可。設定 UI のトグルや起動時の読み込みで上記を呼び出す。設定の永続化(localStorage や Tauri の app 設定)と連携し、「自動起動オン」のときだけプラグインの enable() を呼ぶ。
tauri-plugin-autostart の enable() を実行。disable() を実行。isEnabled() と一致していなければ enable() / disable() で同期する(他ツールでレジストリ等をいじった場合のずれを吸収)。enable() を呼び直し、新しいパスで登録し直す。stateDiagram-v2 [*] --> 設定読み込み 設定読み込み --> 同期: 設定値と isEnabled() が不一致 設定読み込み --> 待機: 一致 同期 --> enableまたはdisable enableまたはdisable --> 待機 待機 --> ユーザーがトグル変更 ユーザーがトグル変更 --> 保存してenable/disable 保存してenable/disable --> 待機