OSX Lion AppleScript : How to get current space # from mission control? -


i'm trying figure out how current space # mission control. source helpful, more helpful info on how figure out myself. i've written few applescripts, more not seems time need new (that can't find dictionary documentation for) falls under category of "tell specific app (e.g. "system events") specific thing" , i've no clue how figure out.


specifically trying do:

i hate new mission control in osx 10.7. want spaces "grid" since used time. used navigate between spaces using arrow keys (e.g. alt+) every few seconds. i'm stuck clunky 1x9 array of spaces instead of elegant 3x3 grid. i've re-mapped spaces use number pad, partially takes care of problem (since 3x3 grid), when have external keyboard attached.

basically, want able use alt+ , again, need detect current space # can switch space 5-->2, example.

dave's answer below, although far more detailed expected, requires writing app (plus still doesn't answer question). if it's @ possible, i'd rather bind few keys applescript.

i'm trying figure out myself. not there yet, in right direction:

  • each mission control "space" gets uuid assigned it...
  • ...except first 1 (afaik), , dashboard one.

you can read them here:

$ defaults read com.apple.spaces $ defaults read com.apple.desktop 

file locations:

~/library/preferences/com.apple.spaces.plist ~/library/preferences/com.apple.desktop.plist 

here's mine. have 4 spaces enabled, , 3 entries show up:

$ defaults read com.apple.spaces {     spaces =     (                 {             type = 0;              uuid = "9f552977-3db0-43e5-8753-e45ac4c61973";         },                 {             type = 0;             uuid = "44c8072a-7dc9-4e83-94dd-bdeaf333c924";         },                 {             type = 0;             uuid = "6fadbdfe-4ce8-4fc9-b535-40d7cc3c4c58";         }     ); } 

if delete space, entry removed file. if add space, entry added. again, there's never entry desktop 1 or dashboard.

i'm not sure if there's public api figure out space uuid being displayed on display. i'd assume no uuid means display 1, , others' mean display 1+n.

i took quick glance through applescript editor library (window ---> library) , didn't see entries under system events spaces. can done cocoa, perhaps via private api, i'm not sure applescript.


update - july 23, 2011

it looks dock controls mission control. can grab header files so:

  1. go to: /system/library/coreservices/dock
  2. right-click , show package contents
  3. navigate: /contents/macos/
  4. copy , paste dock binary desktop.
  5. run: $class-dump ~/desktop/dock

that'll spit out of header files (it's long; 7,500 lines). can see spaceuuid strings appearing in there. there's class called wvspace appears represent single space in mission control, , lot of other wv* classes.

i'll keep looking @ tomorrow; tired now. :)


update - july 24, 2011

inside dock there's class called wvspaces. has number of attributes including:

wvspace *currentspace; unsigned int currentworkspace; wvspace *nextspace;                     // space on right??? wvspace *previousspace;                 // space on left??? bool currentspaceisdashboard; bool dashboardiscurrent; ...lots more... 

each wvspace class has nsstring *_uuid; attribute, spaceuuid. theoretically can current space number so:

wvspace *currentspace = [[wvspaces sharedinstance] currentspace]; nsstring *currentspaceuuid = [currentspace _uuid];     // empty string if main space??? 

the trick is, how access private wvspaces class buried inside of dock? i'm assuming it's singleton has nsmutablearray *_spaces; attribute, every space listed in it. 1 space gets displayed @ time (this holds true if you're using multiple monitors; space spans across both of them), makes sense have 1 wvspaces instance.

so looks it'll require simbl hacking of dock gain access wvspaces.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -