MacでCUIでスタートアップ(Login Items)時に起動するアプリを追加したい


https://github.com/rin1024/AddLoginItem
書いてみました。


使い方は超簡単。
上記をgit cloneなんちゃらして、AddLoginItem.appを追加したいアプリケーションのパスと一緒に実行すればOKです。
例えばテキストエディットを追加したい場合はこんな感じで。

osascript /Applications/AddLoginItem.app /Applications/TextEdit.app

これを実行して"add Login Items, succeeded."ってメッセージがでれば追加されてます。


確認方法としては、
System Preferences -> Users & Groups -> Login Itemsを見れもらえれば追加されてるかと思われます。



※以下、調査してた時のメモ。
あんまやくにたちませんが、なんとなく。


・設定は下記にあある
open ~/Library/Preferences/loginwindow.plist


GUIは以下
http://hp.vector.co.jp/authors/VA010318/intro/ama0112/011231.html


・スタートアップのサービス登録(CUI,batch,shell等)は
ll /Library/StartupItems/
ll /System/Library/StartupItems/
ll ~/Library/LaunchAgents/
ll /Library/LaunchAgents
ll /Library/LaunchDaemons
ll /System/Library/LaunchAgents
ll /System/Library/LaunchDaemons
あたりにstartupなんちゃらをおく


・ログイン時に実行とかであればコレ
sudo defaults write com.apple.loginwindow LoginHook /path/to/batch.sh


・今登録してる情報を参照
defaults read loginwindow | grep Path


・フックスクリプトを見てみる
defaults read loginwindow