OS Xのいろいろな設定をバックアップするツールのモジュールの一つとしてつくったもの。
準備
以下のAppleScriptと簡単なシェルスクリプトを同じフォルダに配置します。
mode.scpt
#!/usr/bin/env osascript
tell application "/Applications/mi.app"
activate
delay 1.0
activate
end tell
tell application "System Events"
tell process "mi"
click menu item "モード設定..." of menu "mi" of menu bar item "mi" of menu bar 1
delay 0.2
tell tab group 1 of window "モード設定"
click radio button "管理"
delay 0.2
click button "モード設定全体のバックアップ保存" of group 1
end tell
end tell
end tell
tell application "Finder"
activate
delay 0.5
set output to (posix path of (the selection as alias))
return output
end tell
mode.sh
#!/bin/sh
mi_config_path=`/usr/bin/env osascript ./mode.scpt`
sleep 0.5
mv "$mi_config_path" "$1"
実行
次に以下のようなコマンドをタイプします。
$ chmod +x mode.sh
$ ./mode.sh mode-backup.zip
すると、カレントディレクトリに mode-backup.zip というアーカイブが書き出されます。このファイルがバックアップデータなので、保管しておきます。
なにをしているのか
-
mode.scpt
はmiを起動し、モード設定のバックアップを書き出す処理を実行させる -
mode.sh
は書き出されたアーカイブをFinder経由で取得し、カレントディレクトリに移動させる