03. Macの起動・再起動時に補助動作を行う ― 2013-04-21
補助と書きましたが、実際にどんな作業を行うかはユーザーによりますので、一例としてご覧ください。
まず起動時の方から。保存したアプリをログイン項目に登録して使っています。
tell application "Finder"
quit
delay 1
launch
open application file "XtraFinder.app" of folder "Applications" of startup disk
end tell
do shell script "killall -HUP KeyRemap4MacBook"
Finderをわざわざ再起動させていますが、これは主要なアプリを置いている外付HDを読み込み直させるためです。起動時の外付HDの読み込みタイミングがどうも遅いために使っているランチャーアプリの表示が変になる症状が続いたので、こんな羽目に(笑)。必然的にXtraFinderも起動し直しです。
KeyRemap4MacBookは立ち上がっていても設定を読み込んでいないようで、再起動すれば直ることがわかりました。
他にここでできることは、ログイン項目で扱うようなことを好みの順番で行わせる、などでしょうか。
次に再起動時、です。
set msg to "Ready to restart Mac now ?"
display dialog msg buttons {"Cancel", "Forward"} default button "Forward"
if (button returned of result) is "Forward" then
tell application "System Events"
set currentProcessNames to name of every application process whose visible is true and name is not "Finder"
repeat with i from 1 to count of currentProcessNames
try
tell application (item i of currentProcessNames) to quit
end try
end repeat
if login item "XtraFinder" exists then
delete login item "XtraFinder"
end if
end tell
tell application "Finder"
delete every item of folder "MainBoot:Users:darzilin:Library:Caches:"
delete every item of folder "MainBoot:Users:darzilin:Library:Preferences:iCab:Databases:"
restart
end tell
end if
行っている順番に
・再起動の確認
そもそも通常終了の確認ダイアログへの応答が面倒で作り始めたのですが、これは無いとやはり痛い目に遭いました(笑)。なのでせめてデフォルトをOKで設置。
・Finder以外のアプリを終了
・ログイン項目XtraFinder削除(現在は不要)
初期のXtraFinderはログイン項目に自動で登録される仕様でした。それがあると上の起動時スクリプトとバッティングすることを発見するのが大変でした。現在は仕様が改良されたので不要な作業ですが、まあ記念ですね(笑)。
・ユーザーキャッシュ、ブラウザの不要ファイル削除
残したFinder担当業務。ブラウザが肥大化するのを好まないので捨てています。
スクリプトからのrestartは待ち時間がありません。起動時にはゴミ箱に排出されたファイルをチラッと見るのが恒例です。
まず起動時の方から。保存したアプリをログイン項目に登録して使っています。
tell application "Finder"
quit
delay 1
launch
open application file "XtraFinder.app" of folder "Applications" of startup disk
end tell
do shell script "killall -HUP KeyRemap4MacBook"
Finderをわざわざ再起動させていますが、これは主要なアプリを置いている外付HDを読み込み直させるためです。起動時の外付HDの読み込みタイミングがどうも遅いために使っているランチャーアプリの表示が変になる症状が続いたので、こんな羽目に(笑)。必然的にXtraFinderも起動し直しです。
KeyRemap4MacBookは立ち上がっていても設定を読み込んでいないようで、再起動すれば直ることがわかりました。
他にここでできることは、ログイン項目で扱うようなことを好みの順番で行わせる、などでしょうか。
次に再起動時、です。
set msg to "Ready to restart Mac now ?"
display dialog msg buttons {"Cancel", "Forward"} default button "Forward"
if (button returned of result) is "Forward" then
tell application "System Events"
set currentProcessNames to name of every application process whose visible is true and name is not "Finder"
repeat with i from 1 to count of currentProcessNames
try
tell application (item i of currentProcessNames) to quit
end try
end repeat
if login item "XtraFinder" exists then
delete login item "XtraFinder"
end if
end tell
tell application "Finder"
delete every item of folder "MainBoot:Users:darzilin:Library:Caches:"
delete every item of folder "MainBoot:Users:darzilin:Library:Preferences:iCab:Databases:"
restart
end tell
end if
行っている順番に
・再起動の確認
そもそも通常終了の確認ダイアログへの応答が面倒で作り始めたのですが、これは無いとやはり痛い目に遭いました(笑)。なのでせめてデフォルトをOKで設置。
・Finder以外のアプリを終了
・ログイン項目XtraFinder削除(現在は不要)
初期のXtraFinderはログイン項目に自動で登録される仕様でした。それがあると上の起動時スクリプトとバッティングすることを発見するのが大変でした。現在は仕様が改良されたので不要な作業ですが、まあ記念ですね(笑)。
・ユーザーキャッシュ、ブラウザの不要ファイル削除
残したFinder担当業務。ブラウザが肥大化するのを好まないので捨てています。
スクリプトからのrestartは待ち時間がありません。起動時にはゴミ箱に排出されたファイルをチラッと見るのが恒例です。
コメント
トラックバック
このエントリのトラックバックURL: http://darzilin.asablo.jp/blog/2013/04/21/6785597/tb
※なお、送られたトラックバックはブログの管理者が確認するまで公開されません。
コメントをどうぞ
※メールアドレスとURLの入力は必須ではありません。 入力されたメールアドレスは記事に反映されず、ブログの管理者のみが参照できます。
※なお、送られたコメントはブログの管理者が確認するまで公開されません。