Skip to content

Commit

Permalink
#108 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Jul 11, 2019
1 parent d9ea6e0 commit 44b6028
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/misc/notify.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#import <Foundation/Foundation.h>
#import <objc/runtime.h>

static bool g_notify_init;
static NSImage *g_notify_img;

@implementation NSBundle(swizzle)
- (NSString *)fake_bundleIdentifier
{
Expand All @@ -12,9 +15,6 @@
}
@end

static bool g_notify_init;
static NSImage *g_notify_img;

static bool notify_init(void)
{
Class c = objc_getClass("NSBundle");
Expand All @@ -29,18 +29,18 @@ static bool notify_init(void)

static void notify(char *message, char *subtitle)
{
@autoreleasepool {

if (!g_notify_init) notify_init();

NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.title = @"yabai";
notification.subtitle = subtitle ? [NSString stringWithUTF8String:subtitle] : NULL;
notification.informativeText = message ? [NSString stringWithUTF8String:message] : NULL;

if (g_notify_img) {
[notification setValue:g_notify_img forKey:@"_identityImage"];
[notification setValue:@(false) forKey:@"_identityImageHasBorder"];
}

[notification setValue:g_notify_img forKey:@"_identityImage"];
[notification setValue:@(false) forKey:@"_identityImageHasBorder"];
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
[notification release];

}
}
4 changes: 4 additions & 0 deletions src/osax/sa.m
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ int scripting_addition_uninstall(void)

int scripting_addition_load(void)
{
@autoreleasepool {

if (!scripting_addition_is_installed()) return 1;

SALoader *loader = [[SALoader alloc] init];
Expand Down Expand Up @@ -359,4 +361,6 @@ int scripting_addition_load(void)
warn("yabai: scripting-addition either failed to load or could not inject payload into Dock.app due to unknown error: %d\n", loader->result);
return 1;
}

}
}

0 comments on commit 44b6028

Please sign in to comment.