Skip to content

Instantly share code, notes, and snippets.

@rien333
Last active January 22, 2018 23:43
Show Gist options
  • Save rien333/9c557a92dbe678059de040ba2a4e7819 to your computer and use it in GitHub Desktop.
Save rien333/9c557a92dbe678059de040ba2a4e7819 to your computer and use it in GitHub Desktop.
Command-line app that tells a bitbar chunkwm plugin to refresh whenever 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