Wednesday, July 30, 2008

Applescript for Space on/off

If you are using Macbook or MBP with big external monitor, you might find that you don't need Space in dual monitor setting.  However, when you find yourself without big shiny monitor, you would miss Space again.

Turning on/off from Space Preference pane every time can be very painful for most of us.

Here is the applescript i am using. This is my first script and i think that i am going to like applescript a lot.

if (do shell script "defaults read com.apple.dock workspaces") is equal to "1" then

do shell script "defaults write com.apple.dock workspaces -bool no;killall Dock"

say "Space turned off"

else

do shell script "defaults write com.apple.dock workspaces -bool yes;killall Dock"

say "Space turned on"

end if


You can use Script Editor to use the script above or you can download little app i made for myself with growl notification and voice prompt.


Download Space Toggler here


4 comments:

Anthony said...

how do i actually use this app? please email me via anthonyfellowsiow@gmail.com

Kevin said...

this is excellent, i frequently switch between a dual monitor and laptop only setup and this saves a lot of clicks!

Kevin said...

this script seems to have effectively killed my assigned spaces / application link. now when i have spaces enabled it clumps them all into space one.... and then even after i have spaces enabled if i turn on an app that is assigned to space 3 it will just pop up in whatever space is active when i launch it... the funny thing is in the spaces pref pane it still lists all of my preferences on what app is assigned where... have you experienced this at all and if so have you found a remedy? email me at kswa1987@gmail.com

Bijan said...

Kevin is correct. This script somehow messes with Spaces settings. Shortcut keys for switching spaces is disabled after using this script - and some of the default space locations are changed.