Reputation: 27399
I wonder if it is possible in 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
Upvotes: 5
Views: 3028
Reputation: 1057
Here is a simple Hello World example to run AppleScript in Objective-C: http://www.sundh.com/blog/2011/12/applescript-in-objective-c/
Upvotes: 0
Reputation: 1
This function has been implemented in the last version of OSX directly in System Preferences -> Exposé & Spaces -> Spaces -> Application Assignments
Upvotes: -1
Reputation: 85095
#!/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
Upvotes: 1
Reputation: 34662
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.
Upvotes: 3