Skip to content

Instantly share code, notes, and snippets.

@rien333
Created January 22, 2018 23:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rien333/59d38c650857fdb1a6d2869a6e5e7af9 to your computer and use it in GitHub Desktop.
Command-line app that tells a bitbar chunkwm plugin to refresh when the user changes spaces
#import <Cocoa/Cocoa.h>
@interface SpaceChangeNotifier : NSObject
- (void) registerNotifier;
- (void)spaceChanged:(NSNotification *)aNotification;
@end
@implementation SpaceChangeNotifier
- (id) init
{
self = [super init];
return self;
}
- (void) registerNotifier {
NSNotificationCenter *nc = [[NSWorkspace sharedWorkspace] notificationCenter];
[nc addObserver:self selector:@selector(spaceChanged:)
name:NSWorkspaceActiveSpaceDidChangeNotification
object:[NSWorkspace sharedWorkspace]];
}
- (void)spaceChanged:(NSNotification *)aNotification {
system("open -g 'bitbar://refreshPlugin?name=chunkwm.*?.fish'");
}
@end
int main(int argc, char *argv[]) {
[NSApplication sharedApplication];
SpaceChangeNotifier *n = [SpaceChangeNotifier new];
[n registerNotifier];
[NSApp run];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment