shabble / osx-space-id

simple Carbon + Cocoa command-line utility to set or retrieve the current Spaces workspace ID.
107 stars 9 forks source link

Doesn't compile on Mavericks #3

Open axelson opened 10 years ago

axelson commented 10 years ago

Unsurprisingly this project doesn't compile on mavericks.

gcc -x objective-c -arch x86_64 -fmessage-length=0 -std=c99 -mmacosx-version-min=10.5 -fpascal-strings -fasm-blocks -framework Foundation -framework Carbon -Wall -o spaces-util main.c
Undefined symbols for architecture x86_64:
  "_CGSSetWorkspace", referenced from:
      _set_space in main-ef4581.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Are there any alternative programs?

I guess I'll see if I can bend this to my needs: https://www.macupdate.com/app/mac/11400/appswitch/

kfix commented 9 years ago

That symbol is a private API, might be gone in a newer OSX.

This replacement is from a gist:

void set_space_by_index(int space)
{
    CFNotificationCenterRef nc = CFNotificationCenterGetDistributedCenter();
    CFStringRef numstr = CFStringCreateWithFormat(NULL, nil, CFSTR("%d"), space);
    CFNotificationCenterPostNotification(nc, CFSTR("com.apple.switchSpaces"), numstr, NULL, TRUE);
}
macalinao commented 7 years ago

@kfix does this work?

tejasmanohar commented 7 years ago

@macalinao no, not on sierra at least.