Skip to content

Commit bffc20c

Browse files
committed
This fixes #57, also resolves #60, resolves #63,
1 parent d129831 commit bffc20c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Diff for: Terminal Notifier/AppDelegate.m

+38
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
NSString * const TerminalNotifierBundleID = @"nl.superalloy.oss.terminal-notifier";
66
NSString * const NotificationCenterUIBundleID = @"com.apple.notificationcenterui";
77

8+
// Set OS Params
9+
#define NSAppKitVersionNumber10_8 1187
10+
#define NSAppKitVersionNumber10_9 1265
11+
812
NSString *_fakeBundleIdentifier = nil;
913

1014
@implementation NSBundle (FakeBundleIdentifier)
@@ -34,6 +38,18 @@ - (NSString *)__bundleIdentifier;
3438
return NO;
3539
}
3640

41+
static BOOL
42+
isMavericks()
43+
{
44+
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_8)
45+
{
46+
/* On a 10.8 - 10.8.x system */
47+
return NO;
48+
} else {
49+
/* 10.9 or later system */
50+
return YES;
51+
}
52+
}
3753

3854
@implementation NSUserDefaults (SubscriptAndUnescape)
3955
- (id)objectForKeyedSubscript:(id)key;
@@ -49,6 +65,28 @@ - (id)objectForKeyedSubscript:(id)key;
4965

5066
@implementation AppDelegate
5167

68+
+(void)initializeUserDefaults
69+
{
70+
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
71+
72+
// initialize the dictionary with default values depending on OS level
73+
NSDictionary *appDefaults;
74+
75+
if (isMavericks())
76+
{
77+
//10.9
78+
appDefaults = @{@"sender": @"com.apple.Terminal"};
79+
}
80+
else
81+
{
82+
//10.8
83+
appDefaults = @{@"": @"message"};
84+
}
85+
86+
// and set them appropriately
87+
[defaults registerDefaults:appDefaults];
88+
}
89+
5290
- (void)printHelpBanner;
5391
{
5492
const char *appName = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"] UTF8String];

0 commit comments

Comments
 (0)