Created
January 22, 2018 23:25
-
-
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
This file contains hidden or 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