10.5: Toggle Spaces on and off via AppleScript

Aug 01, '08 07:30:02AM

Contributed by: Anonymous

I use a big external monitor at work, and carry my MacBook around. I've found that Spaces is not much needed when I have two monitors rather than one. However, bringing up Spaces System Preferences panel just to toggle Spaces on and off is a pain.

So I wrote a small AppleScript that toggels Spaces on and off:

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
Or if you prefer, you can download Space Toggler (20KB), which is a little script application that includes Growl notification. (These scripts originally appeared in this entry in my blog.)

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080730095923129