Skip to content

Commit

Permalink
Merge pull request #9 from henrikbrixandersen/master
Browse files Browse the repository at this point in the history
Add support for NSUserNotification.subtitle
  • Loading branch information
alloy committed Aug 1, 2012
2 parents dc92907 + 282f4ab commit bc33b6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.markdown
Expand Up @@ -67,6 +67,14 @@ The title of the notification. This defaults to ‘Terminal’.

-------------------------------------------------------------------------------

-------------------------------------------------------------------------------

`-subtitle VALUE`

The subtitle of the notification.

-------------------------------------------------------------------------------

`-group ID`

Specifies the ‘group’ a notification belongs to. For any ‘group’ only _one_
Expand Down
6 changes: 6 additions & 0 deletions Terminal Notifier/AppDelegate.m
Expand Up @@ -30,6 +30,7 @@ - (void)printHelpBanner;
" Optional:\n" \
"\n" \
" -title VALUE The notification title. Defaults to ‘Terminal’.\n" \
" -subtitle VALUE The notification subtitle.\n" \
" -group ID A string which identifies the group the notifications belong to.\n" \
" Old notifications with the same ID will be removed.\n" \
" -activate ID The bundle identifier of the application to activate when the user clicks the notification.\n" \
Expand All @@ -50,6 +51,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification;
} else {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

NSString *subtitle = defaults[@"subtitle"];
NSString *message = defaults[@"message"];
NSString *remove = defaults[@"remove"];
if (message == nil && remove == nil) {
Expand All @@ -70,13 +72,15 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification;
if (defaults[@"open"]) options[@"open"] = defaults[@"open"];

[self deliverNotificationWithTitle:defaults[@"title"] ?: @"Terminal"
subtitle:subtitle
message:message
options:options];
}
}
}

- (void)deliverNotificationWithTitle:(NSString *)title
subtitle:(NSString *)subtitle
message:(NSString *)message
options:(NSDictionary *)options;
{
Expand All @@ -85,6 +89,7 @@ - (void)deliverNotificationWithTitle:(NSString *)title

NSUserNotification *userNotification = [NSUserNotification new];
userNotification.title = title;
userNotification.subtitle = subtitle;
userNotification.informativeText = message;
userNotification.userInfo = options;

Expand Down Expand Up @@ -118,6 +123,7 @@ - (void)userActivatedNotification:(NSUserNotification *)userNotification;
NSLog(@"User activated notification:");
NSLog(@" group ID: %@", groupID);
NSLog(@" title: %@", userNotification.title);
NSLog(@" subtitle: %@", userNotification.subtitle);
NSLog(@" message: %@", userNotification.informativeText);
NSLog(@"bundle ID: %@", bundleID);
NSLog(@" command: %@", command);
Expand Down

0 comments on commit bc33b6d

Please sign in to comment.