我在做什么
我运行一个shell脚本,定期检查屏幕的分辨率。在此基础上,它将运行两个苹果脚本中的一个,这基本上改变了另一个应用程序(极客工具)的可见性。
我的问题 apple脚本自己运行得很好。我知道osascript是调用苹果脚本的方式,因为如果我试图直接运行它,它会说"无法执行二进制文件"。然而,当我使用osascript $Home/path/smallscreen.scpt
时,它给了我一个新的错误:
osascript[61390:1405791] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.
Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
也许我只是误解了一些东西,但我认为应该直接从这个答案的底部运行脚本:https://stackoverflow.com/a/16071855/2522073
声称你可以像这样运行你的苹果脚本osascript /Users/USERNAME/Desktop/foo.scpt
Shell代码:
rez=$(xdpyinfo | grep dimensions | awk '{print $2}' | awk -Fx '{print $1, $2}')
echo $rez> $HOME/Documents/Geeklets/Displays_temp.txt
rezold=`grep -s . $HOME/Documents/Geeklets/Displays_temp.txt`
if [ "$rezold" != "$rez" ]; then
if [ "$rez" == "1280 777" ]; then
osascript /Users/coolguy/Documents/Geeklets/smallscreen.scpt
else
$HOME/Scripts/Geeklets/largescreen.scpt
fi
fi
My Apple Script:
tell application "GeekTool Helper"
set smallGroup to group "small"
set largeGroup to group "large"
set defultGroup to group "Default Group"
set visible of smallGroup to true
set visible of largeGroup to false
set visible of defultGroup to true
end tell
我在Mac 10.10.3上运行
这解决了我的问题。https://helpx.adobe.com/photoshop/kb/unit-type-conversion-error-applescript.html
这似乎是32位vs 64位问题的某些方面。不是编码问题!希望这篇文章最终能帮助到别人。