Skip to content

Loading…

Add support for NSUserNotification.subtitle #9

Merged
merged 1 commit into from

2 participants

@henrikbrixandersen

No description provided.

@alloy
Collaborator

Great, thanks!

@alloy alloy merged commit bc33b6d into julienXX:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 14 additions and 0 deletions.
  1. +8 −0 README.markdown
  2. +6 −0 Terminal Notifier/AppDelegate.m
View
8 README.markdown
@@ -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_
View
6 Terminal Notifier/AppDelegate.m
@@ -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" \
@@ -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) {
@@ -70,6 +72,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification;
if (defaults[@"open"]) options[@"open"] = defaults[@"open"];
[self deliverNotificationWithTitle:defaults[@"title"] ?: @"Terminal"
+ subtitle:subtitle
message:message
options:options];
}
@@ -77,6 +80,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification;
}
- (void)deliverNotificationWithTitle:(NSString *)title
+ subtitle:(NSString *)subtitle
message:(NSString *)message
options:(NSDictionary *)options;
{
@@ -85,6 +89,7 @@ - (void)deliverNotificationWithTitle:(NSString *)title
NSUserNotification *userNotification = [NSUserNotification new];
userNotification.title = title;
+ userNotification.subtitle = subtitle;
userNotification.informativeText = message;
userNotification.userInfo = options;
@@ -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);
Something went wrong with that request. Please try again.