*적용중인 도장
https://x86.co.kr/macnews/3505782
Ael님의 스크립트를 수정하여 앱을 수정해보았습니다.
장점이 있다면 터미널이 안보이는 점입니다.
do shell script를 사용해 Terminal이 실행되지 않게끔 수정했습니다.
정상적으로 작동합니다.
타이틀도 추가하였습니다.
스크립트는 마음껏 사용하세요.
--by Ael
set the_script to "pmset -g"
set the_result to do shell script the_script
if contents of the_result does not contain "SleepDisabled" then
do shell script "sudo pmset -a disablesleep 0" with administrator privileges
else if contents of the_result contains "SleepDisabled 1" then
display dialog "잠자기가 비활성화 상태입니다." buttons {"닫기", "활성화"} default button {"활성화"} with title "Sleep Toggle"
if button returned of result = "활성화" then
do shell script "sudo pmset -a disablesleep 0" with administrator privileges
display notification "잠자기가 활성화 되었습니다." with title "Sleep Toggle" sound name "submarine"
end if
else if contents of the result contains "SleepDisabled 0" then
display dialog "잠자기가 활성화 상태입니다." buttons {"닫기", "비활성화"} default button {"비활성화"} with title "Sleep Toggle"
if button returned of result = "비활성화" then
do shell script "sudo pmset -a disablesleep 1" with administrator privileges
tell application "System Events" to activate
display notification "잠자기가 비활성화 되었습니다" with title "Sleep Toggle" sound name "submarine"
end if
end if
P.S. 잠자기가 활성화 되어있는지 안되어있는지 확인해주는 앱을 만들었습니다.
set the_script to "pmset -g"
set the_result to do shell script the_script
if contents of the_result does not contain "SleepDisabled" then
display dialog "잠자기 설정이 보이지 않습니다. 터미널에서 sudo pmset -a disablesleep 0을 실행해주세요." buttons {"닫기"} cancel button {"닫기"} with title "Check SleepDisabled"
else if contents of the_result contains "SleepDisabled 1" then
display dialog "잠자기가 비활성화 상태입니다." buttons {"닫기"} cancel button {"닫기"} with title "Check SleepDisabled"
else if contents of the result contains "SleepDisabled 0" then
display dialog "잠자기가 활성화 상태입니다." buttons {"닫기"} cancel button {"닫기"} with title "Check SleepDisabled"
end if
감사합니다.
저도 잘 쓸께요!