1
我想解决的问题很简单。有没有办法通过Applescript挂钩到OSX睡眠/唤醒事件?
当我打开我的MacBook的盖子时,我喜欢在屏幕的左侧有Dock,但是当我回到家后,将我的MacBook连接到我的Cinema显示屏并设置了双显示器时,电影院的底部,而不是MacBook的左侧。
我不想在每次连接/断开我的Cinema显示时都进入偏好设置。
我有一个问题的50%的解决方案,即我已经编写了以下Applescript代码来根据我的屏幕分辨率切换Dock的位置,但我必须手动调用它。
tell application "Finder"
-- Determine Resolution
set screenSize to bounds of window of desktop
set screenWidth to item 3 of screenSize
set screenHeight to item 4 of screenSize
end tell
if screenWidth is less than 1900 then
--MacBook Display
tell application "System Events"
tell dock preferences
set properties to {magnification:true, screen edge:left}
end tell
end tell
else
--Cinema Display
tell application "System Events"
tell dock preferences
set properties to {magnification:true, screen edge:bottom}
end tell
end tell
end if
我的问题是:
我可以在钩这个代码中直接AppleScript的OSX睡眠/唤醒事件?有没有什么地方可以“注册”脚本以便在我不知道的操作系统事件上调用?
如果不是直接,有什么其他选项挂钩到OSX事件?
对 有任何改善上述Applescript代码的建议吗?
谢谢。