나는 다음과 같은 것을 가지고있다. applescript
번들로 .app
(Platypus 사용) 및 사용자 로그온시 시작 (각 사용자 당 12.4MB)
#!/usr/bin/osascript
-- INICIO DAS FUNCOES EXTRAS
set app_path to path to current application
set app_name to get name of me
set myPath to path to me
tell application "Finder" to set myFolder to (container of myPath) as string
set commonScript to load script alias ((myFolder) & "FuncoesExtras.scpt")
-- FIM DAS FUNCOES EXTRAS
set WhiteList to {app_name, "App Store", "iTunes", "FecharProgramas", "Finder", "Mail"}
repeat
tell application "System Events"
repeat with this_app in (get processes whose background only is false and windows is {})
set NomeDoApp to the name of this_app
if NomeDoApp is not in WhiteList then
try
tell NomeDoApp to quit
log_event("App " & NomeDoApp & " encerrado com sucesso", app_name) of commonScript
on error
do shell script "killall " & quoted form of NomeDoApp
log_event("Forcando interrupcao do App " & NomeDoApp, app_name) of commonScript
end try
end if
end repeat
end tell
tell application "System Events" to set myPID to (unix id of processes whose name is app_name)
do shell script ("/usr/bin/renice 18 " & myPID)
delay 60
end repeat
어떻게하면 서비스로 만들 수 있습니까? 따라서 사용자 로그온이 아닌 시스템이 시작될 때 인스턴스가 1 개만 실행됩니다.
내 코드에 대한 다른 제안 사항이 있습니까?
편집하다
여기 내 현재 (일하는) .plist
에 위치한 /Library/LaunchAgents
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>EnableGlobbing</key>
<false/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>ram.ramon.FecharProgramas</string>
<key>LowPriorityIO</key>
<true/>
<key>Program</key>
<string>Applications/FecharProgramas.app/Contents/MacOS/FecharProgramas</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
내가 그것을 옮길 때. /Library/LaunchDaemons
앱이 더 이상 작동하지 않습니다.
05/10/13 10:43:24,375 FecharProgramas[90]: 3891612: (connect_and_check) Untrusted apps are not allowed to connect to or launch Window Server before login.
05/10/13 10:43:24,376 FecharProgramas[90]: kCGErrorFailure: This user is not allowed access to the window system right now.
05/10/13 10:43:24,376 FecharProgramas[90]: _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
05/10/13 10:43:24,382 FecharProgramas[90]: kCGErrorInvalidConnection: CGSGetEventPort: Invalid connection
내 앱을 신뢰할 필요가 있습니까? 그렇다면 어떻게?
<key>StartInterval</key> <integer>60</integer>
론칭 에이전트에서