Apakah ada cara untuk menyimpan preferensi Mac OS X ke dalam file shell?

17

Setiap kali saya menginstal ulang Mac OS dan / atau membeli Mac baru, saya harus mengkonfigurasi secara manual hampir semua opsi mouse, dock, dll.

Saya ingin tahu apakah Mac OS atau beberapa perangkat lunak dapat memberikan beberapa cara untuk menyimpan semua konfigurasi yang saya setel dengan aplikasi System Preferences ke dalam file shell, membuat sesuatu seperti https://github.com/mathiasbynens/ Mathias Bynens ' dotfiles / blob / master / .macos

Enrico P. Varella
sumber

Jawaban:

11

System Preferences tampaknya disimpan di berbagai tempat, tergantung pada apakah mereka adalah pengguna atau sistem tertentu. Banyak dari mereka disimpan di salah satu /Library/Preferences/atau $HOME/Library/Preferences/(untuk pengaturan per pengguna). Tetapi setiap panel preferensi akan memiliki cara tersendiri untuk menyimpannya.

Anda dapat melihat preferensi mana yang disimpan dengan cara ini dengan mengetik:

defaults read <domain>

Di mana <domain>awal nama file dalam preferensi sistem per pengguna Anda, atau path lengkap ke .plistfile. Sebagai contoh:

defaults read com.apple.screensaver
defaults read /Library/Preferences/com.apple.screensaver

Yang pertama akan menunjukkan kustomisasi per-pengguna dari pengaturan screensaver, sementara yang terakhir akan menampilkan pengaturan screensaver sistem.

Pengaturan sebagian besar diatur oleh panel preferensi, meskipun tidak harus langsung. Anda mungkin harus melihat-lihat dalam /Library/Preferencesdan sub-folder (terutama SystemConfiguration) untuk menemukan semuanya.

Salah satu opsi adalah menyalin file yang relevan keluar, dan menempatkannya kembali untuk instalasi baru.

Cara lain adalah dengan mengekspor dan mengimpor sesuai kebutuhan.

Mengekspor Preferensi Sistem Manajemen Daya (Penghemat Energi) ke pm.plist:

defaults export /Library/Preferences/SystemConfiguration/com.apple.PowerManagement pm.plist

Mengimpor preferensi itu dari pm.plistpada komputer baru:

defaults import /Library/Preferences/SystemConfiguration/com.apple.PowerManagement sysprefs.plist

Anda bahkan mungkin ingin mengedit berbagai .plistfile yang diekspor jika ada preferensi sistem tertentu yang ingin / tidak ingin Anda bagikan antar komputer. Dengan begitu Anda dapat memiliki beberapa penyesuaian secara lokal, dan importperintah tidak akan menimpanya, cukup tambahkan yang sudah Anda atur di .plistfile. Anda dapat menggunakan defaultsperintah untuk memodifikasi .plistfile Anda sendiri (tetapi pastikan Anda menentukan path lengkap ke file, bukan hanya nama, atau Anda dapat memodifikasi preferensi per-pengguna Anda).

drfrogsplat
sumber
1
"com.apple.systempreferences" sebenarnya tidak mengandung preferensi apa pun untuk Sistem. Ini berisi preferensi untuk aplikasi System Preferences. Jadi tidak ada konfigurasi aktual yang Anda lakukan dengan Preferensi Sistem yang disimpan dalam file ini.
Tony Williams
@ TonyWilliams, benar Anda, akan memperbaikinya ...
drfrogsplat
9

Secara otomatis menghasilkan skrip untuk membuat semua perubahan yang diperlukan hampir tidak mungkin. Administrator sistem Mac menghabiskan berjam-jam di bar-bar gelap minum bir atau bourbon dan bertukar bit dari file-file ini - kami enggan berbagi semua pekerjaan itu kecuali Anda siap untuk mengambil tab.

Sebenarnya cara termudah untuk menangkap perubahan konfigurasi adalah dengan menggunakan snapshotting.

Ambil salinan InstallEase dan snapshot Mac baru Anda. Sekarang lakukan semua konfigurasi yang Anda inginkan dan Anda dapat mengambil snapshot lain dan membangun installer yang akan menginstal file yang diubah ke Mac baru.

Tentu saja komplikasi dapat muncul ketika menerapkan perubahan pada versi baru dari sistem operasi, tetapi itu sebabnya kami minum bourbon.

Tony Williams
sumber
Apakah setidaknya ada daftar dengan opsi untuk perintah "default menulis"?
Enrico P. Varella
Tidak. Perintah default dapat menulis ke file preferensi apa pun dalam sistem sehingga tidak mungkin untuk memberikan daftar lengkap.
Tony Williams
Ini ide yang cerdas.
Danijel-James W
1
InstallEase tampaknya tidak tersedia lagi
Sebastian
Casper memiliki alat snapshotting yang dapat Anda gunakan sebagai ganti InstallEase.
Tony Williams
6

Terakhir kali saya melakukan instal ulang bersih saya hanya menyalin seluruh ~/Library/Preferences/folder, dan saya tidak mengalami masalah karena itu. Pengaturan untuk aplikasi versi lama dan pengaturan khusus Mac hanya boleh diabaikan. Hampir tidak ada file dalam ~/Library/Preferences/instalasi baru, dan jika Anda menghapus semua file ~/Library/Preferences/, file preferensi akan dibuat kembali ketika dibutuhkan.

File preferensi untuk aplikasi kotak pasir sekarang disimpan ~/Library/Containers/, tetapi saya tidak tahu apakah menyalinnya ke Mac lain akan menyebabkan masalah.

Anda mungkin juga menggunakan Asisten Migrasi .

Atau jika Anda pergi .osxrute, Anda dapat membedakan output dari defaults read:

  1. Lari defaults read|awk 'length<200'>/tmp/a
  2. Ubah beberapa pengaturan
  3. Lari defaults read|awk 'length<200'>/tmp/b;diff /tmp/[ab]

Anda dapat menjalankan sudo opensnoopatau menggunakan fseventer untuk melihat file apa yang dimodifikasi ketika Anda mengubah preferensi dari GUI.

Lri
sumber
3

Setelah berjam-jam menemukan sesuatu yang paling tidak berguna untuk masalah saya, saya menemukan sebuah situs web yang disebut Rahasia , yang menyediakan banyak perintah umum Mac OS "default menulis".

Pokoknya, terima kasih kepada Tony dan drfrogsplatless karena memberi saya klarifikasi dan tips yang membantu saya.

(edit: situs offline, menggunakan versi yang diarsipkan)

Enrico P. Varella
sumber
web.archive.org/web/20150322005829/http://secrets.blacktree.com ? memiliki salinan arsip sejak September 2015.
ecmanaut
1

Mackup adalah apa yang Anda cari. https://github.com/lra/mackup/tree/master/doc

Laurent
sumber
Mackup terlihat seperti alat yang luar biasa tetapi tidak mendukung penulisan default. Juga ini menjelaskan lebih baik daripada tautan yang Anda berikan: github.com/lra/mackup
ClintM
1

Berikut adalah sebagian Script Apple yang saya selesaikan pada bulan Agustus 2016 untuk Mac saya, yang diposting di sini sebagai, "bukti konsep" agak kuat, tetapi ini sesuatu yang dapat Anda mainkan:

(* Sebelum menjalankan skrip ini, Anda harus terlebih dahulu memberikan celana ketat Apple Script di bawah System Preferences -> Security & Privacy -> Aksesibilitas dan memungkinkan Apple Script untuk mengontrol komputer. Anda dapat memulai dengan menjalankan skrip hingga gagal pada saat itu. Lalu hentikan skrip, arahkan ke dialog Preferensi itu, dan centang kotak di sebelah Script Editor. Kemudian Anda dapat kembali, hapus semua tangkapan layar yang sudah diambil (untuk menghindari duplikat yang membingungkan), dan mulai skrip lagi.

Mengapa Anda perlu melakukan ini? Karena beberapa dialog preferensi, setelah dibuka dan "difoto," harus ditutup secara eksplisit dengan klik mouse pada tombol Batal. Apple Script tidak dapat melakukan itu kecuali ia memiliki hak "untuk mengontrol komputer Anda" di dalam pref. *)

tell application "System Preferences" to quit
delay 0.25

-- MAKE THE PREFS PICS FOLDER ON THE DESKTOP IF IT ISN'T THERE ALREADY.
-- IF IT IS THERE ALREADY, NO CHECKING IS DONE WITH REFERENCE TO WHATEVER FILES ARE IN IT.
tell application "Finder"
    if not (exists folder "Prefs Pics" of desktop) then
        make new folder with properties {name:"Prefs Pics", location:"desktop"}
    end if
end tell

tell application "System Preferences"
    activate

-- THE PREFS ARE ORDERED BELOW ALPHABETICALLY. TO HAVE THEM SAVE THAT WAY, REMOVE THE ORDER ID (oid) VARIABLE FROM THE CODE LINE SETTING EACH FILENAME. OTHERWISE THE FILENAME WILL BE SET BASED ON THE GROUP AND ICON NUMBERS (ROW AND COLUMN) AS DISPLAYED WHEN SYSTEM PREFS ARE ARRANGED BY CATEGORY.
-- GROUP 4 NO 3 APP STORE
set oid to 43
set current pane to pane "com.apple.preferences.appstore"
-- Now that the first pref window is up, get its name and assign it to a variable
set nid to (get name of first window whose visible is true)
-- Do the same for its ID
set wid to (get id of first window whose visible is true)
-- Now wait one second and capture the window, passing the wid varialble to screencapture's -l switch and the nid variable to the filename to be used, and save the file
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"
-- note you can't be messing around with the computer until the script ends; otherwise you'll interfere and prolly capture wrong winders

-- GROUP 4 NO 7 TIME MACHINE
set oid to 47
set current pane to pane "com.apple.prefs.backup"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 3 NO 5 BLUETOOTH
set oid to 35
set current pane to pane "com.apple.preferences.Bluetooth"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 4 NO 5 DATE & TIME
set oid to 45
set current pane to pane "com.apple.preference.datetime"
reveal anchor "DateTimePref" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "TimeZonePref" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "ClockPref" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 1 NO 2 DESKTOP & SCREEN SAVER                                              -- NEEDS TROUBLESHOOTING TO SELECT LEFT PANE IN DESKTOP TAB
set oid to 12
set current pane to pane "com.apple.preference.desktopscreeneffect"
-- reveal anchor "DesktopPref" of current pane
-- set nid to (get name of first window whose visible is true)
-- set wid to (get id of first window whose visible is true)
-- do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "ScreenSaverPref" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 2 NO 1 DISPLAYS
set oid to 21
set current pane to pane "com.apple.preference.displays"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"
-- reveal anchor "displaysArrangementTab" of current pane                   -- NEEDS TROUBLESHOOTING
-- reveal anchor "displaysColorTab" of current pane                         -- NEEDS TROUBLESHOOTING
-- reveal anchor "displaysGeometryTab" of current pane                      -- NEEDS TROUBLESHOOTING
-- reveal anchor "displaysDisplayTab"                                               -- NEEDS TROUBLESHOOTING

-- GROUP 1 NO 3 DOCK
set oid to 13
set current pane to pane "com.apple.preference.dock"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 2 NO 2 ENERGY SAVER
set oid to 22
set current pane to pane "com.apple.preference.energysaver"
--  reveal anchor "Schedule" of current pane                                        -- NEEDS TO BE CLOSED BEFORE MOVING ON

-- GROUP 1 NO 4 MISSION CONTROL
set oid to 14
set current pane to pane "com.apple.preference.expose"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 3 NO 3 EXTENSIONS
set oid to 33
set current pane to pane "com.apple.preferences.extensions"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 1 NO 1 GENERAL
set oid to 11
set current pane to pane "com.apple.preference.general"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 3 NO 1 ICLOUD  
-- set oid to 31
-- set current pane to pane "com.apple.preferences.icloud"                  -- THIS PREFERENCE WAS NOT COPIED

-- GROUP 3 NO 2 INTERNET ACCOUNTS
-- set oid to 32
-- set current pane to pane "com.apple.preferences.internetaccounts"        -- THIS PREFERENCE WAS NOT COPIED

-- GROUP 2 NO 3 KEYBOARD
set oid to 23
set current pane to pane "com.apple.preference.keyboard" -- NEEDS TROUBLESHOOTING
reveal anchor "keyboardTab" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Text" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "shortcutsTab" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "InputSources" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "keyboardTab_ModifierKeys" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

tell application "System Events" to tell process "System Preferences"
    click button "Cancel" of sheet 1 of window "Keyboard"
end tell

-- GROUP 1 NO 5 LANGUAGE & REGTION
set oid to 15
set current pane to pane "com.apple.Localization"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Region" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Language" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 2 NO 4 MOUSE
set oid to 14
set current pane to pane "com.apple.preference.mouse"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 3 NO 4 NETWORK
--  set oid to 34
--  set current pane to pane "com.apple.preference.network"

-- GROUP 1 NO 8 NOTIFICATIONS
-- set oid to 18
-- set current pane to pane "com.apple.preference.notifications"

-- GROUP 4 NO 2 PARENTAL CONTROLS
-- set oid to 42
--  set current pane to pane "com.apple.preferences.parentalcontrols"

-- GROUP 2 NO 6 PRINTERS & SCANNERS
--  set oid to 26   
--  set current pane to pane "com.apple.preference.printfax"
-- reveal anchor "fax" of current pane
--  reveal anchor "share" of current pane
--  reveal anchor "print" of current pane
-- reveal anchor "scan" of current pane

-- GROUP 1 NO 6 SECURITY & PRIVACY
set oid to 16
set current pane to pane "com.apple.preference.security"
reveal anchor "General" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "FDE" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Firewall" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Privacy" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Privacy_LocationServices" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Privacy_Contacts" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Privacy_Calendars" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Privacy_Reminders" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Privacy_Facebook" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Privacy_Accessibility" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Privacy_Diagnostics" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"
--  reveal anchor "Privacy_Twitter" of current pane
--  reveal anchor "Privacy_Weibo" of current pane
--  reveal anchor "Privacy_TencentWeibo"
--  reveal anchor "Privacy_Assistive" of current pane
--  reveal anchor "Privacy_LinkedIn" of current pane
--  reveal anchor "Advanced" of current pane

-- GROUP 3 NO 6 SHARING
set oid to 36
set current pane to pane "com.apple.preferences.sharing"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 2 NO 7 SOUND
set oid to 27
set current pane to pane "com.apple.preference.sound"
reveal anchor "effects" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "output" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "input" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 4 NO 4 DICTATION & SPEECH
set oid to 44
set current pane to pane "com.apple.preference.speech"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "TTS" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Dictation" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 1 NO 7 SPOTLIGHT
set oid to 17
set current pane to pane "com.apple.preference.spotlight"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "privacy" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "searchResults" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 4 NO 6 STARTUP DISK
set oid to 46
set current pane to pane "com.apple.preference.startupdisk"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 2 NO 5 TRACKPAD
set oid to 25
set current pane to pane "com.apple.preference.trackpad"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 4 NO 1 USERS & GROUPS
set oid to 41
set current pane to pane "com.apple.preferences.users"
reveal anchor "passwordPref" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "startupItemsPref" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "loginOptionsPref" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

--  reveal anchor "mobilityPref" of current pane
--  set nid to (get name of first window whose visible is true)
--  set wid to (get id of first window whose visible is true)
--  do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

-- GROUP 4 NO 8 ACCESSIBILITY
set oid to 48
set current pane to pane "com.apple.preference.universalaccess"
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Seeing_VoiceOver" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Switch" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Keyboard" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Seeing_Display" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Hearing" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Seeing_Zoom" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "SpeakableItems" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Media_Descriptions" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Mouse" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"

reveal anchor "Captioning" of current pane
set nid to (get name of first window whose visible is true)
set wid to (get id of first window whose visible is true)
do shell script "screencapture -T1 -l" & wid & " ~/Desktop/Prefs\\ Pics/" & oid & "\\ " & quoted form of (nid) & "\\ " & "$(date +%Y-%m-%d-%H%M%S).png"
end tell
tell application "System Preferences" to quit


-- HELPERS FOR THE HOMEWORK THAT NEEDED TO BE DONE BEFORE THE SCRIPT COULD BE WROTEN
-- GET ALL PANE ID'S
-- tell application "System Events"
-- tell application "System Preferences"
-- get the id of every pane
-- end tell
-- end tell


-- GET ALL PANE NAMES
-- tell application "System Preferences"
-- name of panes
-- end tell


-- GET THE ANCHOR NAME FOR A PARTICULAR PANE
-- tell application "System Preferences"
-- activate
-- get the name of every anchor of pane id "com.apple.preferences.users"
-- end tell
Steve
sumber