【設定】NSDisableAutomaticTermination をTRUE =AutomaticTermination しないようにする
【スクリプトエディタで開く】 |
【設定】AutomaticTermination.scpt | ソース |
|---|
| 001 | #!/usr/bin/env osascript |
| 002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
| 003 | (* |
| 004 | AutomaticTerminationの設定を変更します |
| 005 |
|
| 006 | 1:GlobalPreferences |
| 007 | 2:com.apple.Preview の設定で |
| 008 | AutomaticTerminationが無効にします |
| 009 |
|
| 010 | AutomaticTerminationについては |
| 011 | https://note.com/quicktimer/n/n43da194743c9 |
| 012 |
|
| 013 |
|
| 014 | 設定終了後は |
| 015 | ログアウトーログイン |
| 016 | 又は |
| 017 | デバイスの電源OFFーONをしてはじめて適応されます |
| 018 |
|
| 019 |
|
| 020 | com.cocolog-nifty.quicktimer.icefloe *) |
| 021 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
| 022 | use AppleScript version "2.8" |
| 023 | use framework "Foundation" |
| 024 | use framework "AppKit" |
| 025 | use framework "UniformTypeIdentifiers" |
| 026 | use scripting additions |
| 027 |
|
| 028 | property refMe : a reference to current application |
| 029 |
|
| 030 | tell application id "com.apple.Preview" to quit |
| 031 | ########### |
| 032 | #NSGlobalDomain |
| 033 | set strCmd to ("/usr/bin/defaults read NSGlobalDomain NSDisableAutomaticTermination") as text |
| 034 | set strStdOut to (do shell script strCmd) as text |
| 035 | if strStdOut is "0" then |
| 036 | set strCmd to ("/usr/bin/defaults write -globalDomain NSDisableAutomaticTermination -bool true") as text |
| 037 | set strStdOut to (do shell script strCmd) as text |
| 038 | end if |
| 039 | delay 0.25 |
| 040 | set strCmd to ("/usr/bin/defaults read NSGlobalDomain NSDisableAutomaticTermination") as text |
| 041 | set strStdOut to (do shell script strCmd) as text |
| 042 | if strStdOut is "0" then |
| 043 | log "NSGlobalDomainの設定が変更できませんでした:0" |
| 044 | else if strStdOut is "1" then |
| 045 | log "NSGlobalDomainの設定が正しく変更されました:1" |
| 046 | end if |
| 047 | ########### |
| 048 | #com.apple.Preview |
| 049 | set strCmd to ("/usr/bin/defaults read com.apple.Preview NSDisableAutomaticTermination") as text |
| 050 | set strStdOut to (do shell script strCmd) as text |
| 051 | if strStdOut is "0" then |
| 052 | set strCmd to ("/usr/bin/defaults write com.apple.Preview NSDisableAutomaticTermination -bool true") as text |
| 053 | set strStdOut to (do shell script strCmd) as text |
| 054 | end if |
| 055 | delay 0.25 |
| 056 | set strCmd to ("/usr/bin/defaults read com.apple.Preview NSDisableAutomaticTermination") as text |
| 057 | set strStdOut to (do shell script strCmd) as text |
| 058 | if strStdOut is "0" then |
| 059 | log "NSGlobalDomainの設定が変更できませんでした:0" |
| 060 | else if strStdOut is "1" then |
| 061 | log "NSGlobalDomainの設定が正しく変更されました:1" |
| 062 | end if |
| 063 |
|
| 064 |
|
| 065 | return |
| AppleScriptで生成しました |
|---|