애플 스크립트를 사용하여 앱이 실행 중인지 확인하고 확인할 수 있습니다. http://macosx.com/forums/1199085-post2.html
global wasLoaded
on run
set wasLoaded to isAppLoaded("Safari")
idle
end run
on idle
set x to isAppLoaded("Safari")
if x and not wasLoaded then
do shell script "SOME BASH COMMAND" -- stop your launchd task
set wasLoaded to true
else if wasLoaded and not x then
do shell script "SOME BASH COMMAND" -- start your launchd task
set wasLoaded to false
end if
return 1 --will wait 1 second before checking again
end idle
on isAppLoaded(app_name)
tell application "System Events"
set app_list to every application process whose name contains app_name
if the (count of app_list) > 0 then
return true
else
return false
end if
end tell
end isAppLoaded
I 출력을 구문 분석하여 수행 bash
스크립터가 같은 일을하는 당신에게 방법을 말할 수있는 확신 :
나는 응용 프로그램의 시작 및 종료를 모니터링 할 AppleScript로 설명이 게시물을 발견
top
에서.
Apple documentation for do shell script
안녕하세요 브라이언 : 해당 코드를 제공해 주셔서 감사합니다. :) 정말 감사. AppleScript로는 좋지 않은 것처럼 몇 가지 질문이 있습니다. 우선, 내 launchd 프로세스를 종료하거나 단순히 내 앱이 실행 중인지 살펴 봅니까? 또한이 파일을 내 launchd 파일에 어떻게 통합하여 UNIX 코드를 먼저 실행하지 않습니까? 감사합니다. – PF1
launchd 프로세스를 시작하고 중지하려면 줄을 채워야합니다. launchd를 모르므로 정확한 명령이 무엇인지 알 수 없습니다. 나는 조금 더 채우기 위해 코드를 업데이트했다. –
헤이 브라이언 : 도와 줘서 고마워. 나는 유닉스 등으로 결과를 변형시키지 않고도 작동 할 수 있도록 마침내 방법을 찾아 냈다. 유닉스를 파싱하여 애플 스크립트로 만들었다. :) 그 아이디어에 대해 감사해야합니다. – PF1