Bash和Mac OS X,在Space N中打开应用程序

时间:2010-02-21 12:21:50

标签: bash macos

我想知道在OSX的bash中是否有可能创建一个脚本,我们将其作为输入提供应用程序名称和数字N,因此该应用程序将在Space的空格编号N中打开。

我想用这个来创建一个元脚本,所以当计算机启动和登录后,在每个空间我得到不同的应用程序,重要的是,我可以在脚本文件中更改它,而不是通过mac os x空间的偏好

由于

4 个答案:

答案 0 :(得分:2)

defaults write com.apple.dock workspaces-app-bindings -dict-add com.apple.safari 4

从命令行执行的操作与更改空格首选项以将safari放在空格编号4中相同.65544会将其放在所有空格中。

正如您所看到的,它是进行空间绑定的底座。

答案 1 :(得分:1)

#!/bin/sh
APPNAME=$1
SPACE=$2
APPID=$(osascript - <<EOF1 | tr '[:upper:]' '[:lower:]'
tell application "Finder"
    get id of application file "$APPNAME" of folder "Applications" of startup disk
end tell
EOF1
)
osascript - <<EOF2
tell application "System Events"
    set x to application bindings of spaces preferences of expose preferences
    set x to {|$APPID|:$SPACE} & x
    set application bindings of spaces preferences of expose preferences to x
end tell
EOF2

答案 2 :(得分:0)

这是一个在Objective-C中运行AppleScript的简单Hello World示例: http://www.sundh.com/blog/2011/12/applescript-in-objective-c/

答案 3 :(得分:-1)

此功能已在OSX的最新版本中直接在系统偏好设置中实现 - &gt; Exposé&amp;空间 - &gt;空间 - &gt;申请分配

相关问题