Created
January 22, 2018 23:25
Star
You must be signed in to star a gist
Command-line app that tells a bitbar chunkwm plugin to refresh when the user changes spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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