Archive for the 'Mac' Category

AppleScript Snippet: Set spaces shortcut key to ctrl-option

Wednesday, January 30th, 2008

So yes it happened. I switched over to using Apple hardware and OS X on my primary laptop. I’ve been very happy with my iPhone. When my girlfriend decided to buy a new TV, I thought it would be nice to have a media computer of some sort to drive the 1080p display. My good friend Brian was selling a 1st-generation Intel Mac Mini (A Core Solo), so I thought, “What the hell, why not?”

Turns out Leopard is pretty cool. OS X has come a long way since I poked at versions 10.1 and 10.2 while trying to maintain the machines in the SourceForge.net compile farm. After poking around under the hood and getting acquainted with launchd while trying to get openvpn to start on startup, I realized that it really is serious Unix, that Apple has done some really neat stuff, and that it really does have a prettier face than I’ve ever seen on a Unix box.

At that point, I started seriously thinking about buying a Mac. I knew that MacWorld was coming and rumors were flying about a new ultra-light laptop, so I took a wait-and-see-attitude. After seeing that I would only want the Air in a $3000 configuration, I went and bought the MacBook that I’ve wanted since it was released: the black one.

In short: I love it and I’ve been using it enough to start to get annoyed by it. For example, by default, the Spaces preferences allow you to choose a single modifier key for moving around spaces. On Linux, I use Ctrl-Alt-Arrow to move desktops, since nothing else really uses that; it allows application bindings to shine through and continue to work.

So I started fighting with AppleScript to see if I could get it to do what I wanted. It took some frustration (most new languages do), and I will pronounce AppleScript supremely weird if not totally readable. In the end, this was what I wanted:


tell application "System Events"
	tell expose preferences
		tell spaces preferences
			tell arrow key modifiers
				set properties to {key modifiers:{control, option}}
				get properties
			end tell
		end tell
	end tell
end tell

I hope this is useful to someone. Enjoy.