开发者

Bash and Mac OS X, open application in Space N

I wonder if it is possible 开发者_如何学Cin bash for OSX to create a script for which we give as input the application name and a number N, so this app gets opened in the Space's space number N.

I would like with this to create a meta-script, so when the computer boots and after login, on each space I get different apps, and important, I can change this in the script file, and not through mac os x Space's preferences

Thanks


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

That does from the command line the same thing as changing the spaces preferences to put safari in space number 4. 65544 would put it on all spaces.

As you can see, it's the dock that does the space binding.


#!/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


Here is a simple Hello World example to run AppleScript in Objective-C: http://www.sundh.com/blog/2011/12/applescript-in-objective-c/


This function has been implemented in the last version of OSX directly in System Preferences -> Exposé & Spaces -> Spaces -> Application Assignments

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜