terminal-notifier 1.6.3 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/vendor/terminal-notifier/README.markdown +63 -4
- data/vendor/terminal-notifier/Terminal Notifier/AppDelegate.m +281 -69
- data/vendor/terminal-notifier/Terminal Notifier/Terminal Notifier-Info.plist +5 -3
- data/vendor/terminal-notifier/terminal-notifier.app/Contents/Info.plist +15 -9
- data/vendor/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier +0 -0
- data/vendor/terminal-notifier/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96140bb35740bd35bddea3e2e202a32cf1617a1f
|
4
|
+
data.tar.gz: 2f170c56de4b2721ec500173a4103bd86fe60390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29ec5f7c96e9be0a0610a9151634edd0eb1e9761a48d6ed86a3b4e2d60338cf30a75bf1fd13068cb653bd32ffcf640f2fdbe9867c56cdb689b1d4eb4a8b319aa
|
7
|
+
data.tar.gz: 0ac46c139e48faf4d4140b6ae8f451b115c870e499450af99dd28989eb8768094fb2ab8c4d5ab893b1e44837988dbc4738cfa337ec736f016bce69e82ad61728
|
@@ -27,7 +27,7 @@ which are available in Mac OS X 10.8 and higher.
|
|
27
27
|
## Download
|
28
28
|
|
29
29
|
Prebuilt binaries are available from the
|
30
|
-
[releases section](https://github.com/
|
30
|
+
[releases section](https://github.com/julienXX/terminal-notifier/releases).
|
31
31
|
|
32
32
|
Or if you want to use this from
|
33
33
|
[Ruby](https://github.com/alloy/terminal-notifier/tree/master/Ruby), you can
|
@@ -37,7 +37,7 @@ install it through RubyGems:
|
|
37
37
|
$ [sudo] gem install terminal-notifier
|
38
38
|
```
|
39
39
|
|
40
|
-
You can also install it via [Homebrew](https://github.com/
|
40
|
+
You can also install it via [Homebrew](https://github.com/Homebrew/homebrew):
|
41
41
|
```
|
42
42
|
$ brew install terminal-notifier
|
43
43
|
```
|
@@ -62,9 +62,28 @@ This will obviously be a bit slower than using the tool without the wrapper.
|
|
62
62
|
|
63
63
|
Some examples are:
|
64
64
|
|
65
|
+
Display piped data with a sound
|
65
66
|
```
|
66
67
|
$ echo 'Piped Message Data!' | terminal-notifier -sound default
|
68
|
+
```
|
69
|
+
|
70
|
+
Multiple actions and custom dropdown list
|
71
|
+
```
|
72
|
+
$ terminal-notifier -message "Deploy now on UAT ?" -actions Now,"Later today","Tomorrow" -dropdownLabel "When ?"
|
73
|
+
```
|
74
|
+
|
75
|
+
Yes or No ?
|
76
|
+
```
|
77
|
+
$ terminal-notifier -title ProjectX -subtitle "new tag detected" -message "Deploy now on UAT ?" -closeLabel No -actions Yes -appIcon http://vjeantet.fr/images/logo.png
|
78
|
+
```
|
79
|
+
|
80
|
+
Open an URL when the notification is clicked
|
81
|
+
```
|
67
82
|
$ terminal-notifier -title '💰' -message 'Check your Apple stock!' -open 'http://finance.yahoo.com/q?s=AAPL'
|
83
|
+
```
|
84
|
+
|
85
|
+
Open an app when the notification is clicked
|
86
|
+
```
|
68
87
|
$ terminal-notifier -group 'address-book-sync' -title 'Address Book Sync' -subtitle 'Finished' -message 'Imported 42 contacts.' -activate 'com.apple.AddressBook'
|
69
88
|
```
|
70
89
|
|
@@ -104,6 +123,46 @@ in Sound Preferences. Use 'default' for the default notification sound.
|
|
104
123
|
|
105
124
|
-------------------------------------------------------------------------------
|
106
125
|
|
126
|
+
`-reply`
|
127
|
+
|
128
|
+
The notification will be displayed as a reply type alert.
|
129
|
+
|
130
|
+
-------------------------------------------------------------------------------
|
131
|
+
|
132
|
+
`-actions VALUE1,VALUE2,"VALUE 3"`
|
133
|
+
|
134
|
+
The notification actions avalaible.
|
135
|
+
When you provide more than one value, a dropdown will be displayed.
|
136
|
+
You can customize this dropdown label with the next option
|
137
|
+
Does not work when -reply is used
|
138
|
+
|
139
|
+
-------------------------------------------------------------------------------
|
140
|
+
|
141
|
+
`-dropdownLabel VALUE`
|
142
|
+
|
143
|
+
The notification actions dropdown title (only when multiples -actions values are provided).
|
144
|
+
Does not work when -reply is used
|
145
|
+
|
146
|
+
-------------------------------------------------------------------------------
|
147
|
+
|
148
|
+
`-closeLabel VALUE`
|
149
|
+
|
150
|
+
The notification "Close" button label.
|
151
|
+
|
152
|
+
-------------------------------------------------------------------------------
|
153
|
+
|
154
|
+
`-timeout NUMBER`
|
155
|
+
|
156
|
+
Auto close the alert notification after NUMBER seconds.
|
157
|
+
|
158
|
+
-------------------------------------------------------------------------------
|
159
|
+
|
160
|
+
`-json`
|
161
|
+
|
162
|
+
Outputs the event as JSON.
|
163
|
+
|
164
|
+
-------------------------------------------------------------------------------
|
165
|
+
|
107
166
|
`-group ID`
|
108
167
|
|
109
168
|
Specifies the ‘group’ a notification belongs to. For any ‘group’ only _one_
|
@@ -159,8 +218,8 @@ application instead, including using its icon.
|
|
159
218
|
Using this option fakes the sender application, so that the notification system
|
160
219
|
will launch that application when the notification is clicked. Because of this
|
161
220
|
it is important to note that you cannot combine this with options like
|
162
|
-
`-execute
|
163
|
-
‘terminal-notifier’ to perform its work.
|
221
|
+
`-execute`, `-open`, and `-activate` which depend on the sender of the
|
222
|
+
notification to be ‘terminal-notifier’ to perform its work.
|
164
223
|
|
165
224
|
For information on the `ID` see the `-activate` option.
|
166
225
|
|
@@ -12,6 +12,7 @@ NSString * const NotificationCenterUIBundleID = @"com.apple.notificationcenterui
|
|
12
12
|
#define contains(str1, str2) ([str1 rangeOfString: str2 ].location != NSNotFound)
|
13
13
|
|
14
14
|
NSString *_fakeBundleIdentifier = nil;
|
15
|
+
NSUserNotification *currentNotification = nil;
|
15
16
|
|
16
17
|
@implementation NSBundle (FakeBundleIdentifier)
|
17
18
|
|
@@ -102,10 +103,25 @@ isMavericks()
|
|
102
103
|
" or use ‘ALL’ as ID to see all notifications.\n" \
|
103
104
|
" The output is a tab-separated list.\n"
|
104
105
|
"\n" \
|
106
|
+
" Reply type notification:\n" \
|
107
|
+
"\n" \
|
108
|
+
" -reply VALUE The notification will be displayed as a reply type alert, VALUE used as placeholder.\n" \
|
109
|
+
"\n" \
|
110
|
+
" Actions type notification:\n" \
|
111
|
+
"\n" \
|
112
|
+
" -actions VALUE1,VALUE2.\n" \
|
113
|
+
" The notification actions avalaible.\n" \
|
114
|
+
" When you provide more than one value, a dropdown will be displayed.\n" \
|
115
|
+
" You can customize this dropdown label with the next option.\n" \
|
116
|
+
" -dropdownLabel VALUE\n" \
|
117
|
+
" The notification actions dropdown title (only when multiples actions are provided).\n" \
|
118
|
+
" Notification style must be set to Alert.\n" \
|
119
|
+
"\n" \
|
105
120
|
" Optional:\n" \
|
106
121
|
"\n" \
|
107
122
|
" -title VALUE The notification title. Defaults to ‘Terminal’.\n" \
|
108
123
|
" -subtitle VALUE The notification subtitle.\n" \
|
124
|
+
" -closeLabel VALUE The notification close button label.\n" \
|
109
125
|
" -sound NAME The name of a sound to play when the notification appears. The names are listed\n" \
|
110
126
|
" in Sound Preferences. Use 'default' for the default notification sound.\n" \
|
111
127
|
" -group ID A string which identifies the group the notifications belong to.\n" \
|
@@ -116,6 +132,8 @@ isMavericks()
|
|
116
132
|
" -contentImage URL The URL of a image to display attached to the notification (Mavericks+ only)\n" \
|
117
133
|
" -open URL The URL of a resource to open when the user clicks the notification.\n" \
|
118
134
|
" -execute COMMAND A shell command to perform when the user clicks the notification.\n" \
|
135
|
+
" -timeout NUMBER Close the notification after NUMBER seconds.\n" \
|
136
|
+
" -json Output event or value to stdout as JSON \n" \
|
119
137
|
"\n" \
|
120
138
|
"When the user activates a notification, the results are logged to the system logs.\n" \
|
121
139
|
"Use Console.app to view these logs.\n" \
|
@@ -123,7 +141,7 @@ isMavericks()
|
|
123
141
|
"Note that in some circumstances the first character of a message has to be escaped in order to be recognized.\n" \
|
124
142
|
"An example of this is when using an open bracket, which has to be escaped like so: ‘\\[’.\n" \
|
125
143
|
"\n" \
|
126
|
-
"For more information see https://github.com/
|
144
|
+
"For more information see https://github.com/julienXX/terminal-notifier.\n",
|
127
145
|
appName, appVersion, appName);
|
128
146
|
}
|
129
147
|
|
@@ -187,26 +205,45 @@ isMavericks()
|
|
187
205
|
|
188
206
|
if (message) {
|
189
207
|
NSMutableDictionary *options = [NSMutableDictionary dictionary];
|
190
|
-
if (defaults[@"activate"])
|
191
|
-
if (defaults[@"group"])
|
192
|
-
if (defaults[@"execute"])
|
193
|
-
if (defaults[@"appIcon"])
|
194
|
-
if (defaults[@"contentImage"])
|
208
|
+
if (defaults[@"activate"]) options[@"bundleID"] = defaults[@"activate"];
|
209
|
+
if (defaults[@"group"]) options[@"groupID"] = defaults[@"group"];
|
210
|
+
if (defaults[@"execute"]) options[@"command"] = defaults[@"execute"];
|
211
|
+
if (defaults[@"appIcon"]) options[@"appIcon"] = defaults[@"appIcon"];
|
212
|
+
if (defaults[@"contentImage"]) options[@"contentImage"] = defaults[@"contentImage"];
|
213
|
+
if (defaults[@"closeLabel"]) options[@"closeLabel"] = defaults[@"closeLabel"];
|
214
|
+
if (defaults[@"dropdownLabel"]) options[@"dropdownLabel"] = defaults[@"dropdownLabel"];
|
215
|
+
if (defaults[@"actions"]) options[@"actions"] = defaults[@"actions"];
|
216
|
+
|
217
|
+
if([[[NSProcessInfo processInfo] arguments] containsObject:@"-reply"] == true) {
|
218
|
+
options[@"reply"] = @"Reply";
|
219
|
+
if (defaults[@"reply"]) options[@"reply"] = defaults[@"reply"];
|
220
|
+
}
|
221
|
+
|
222
|
+
options[@"output"] = @"outputEvent";
|
223
|
+
if([[[NSProcessInfo processInfo] arguments] containsObject:@"-json"] == true) {
|
224
|
+
options[@"output"] = @"json";
|
225
|
+
}
|
226
|
+
|
227
|
+
options[@"timeout"] = @"0";
|
228
|
+
if (defaults[@"timeout"]) options[@"timeout"] = defaults[@"timeout"];
|
229
|
+
|
195
230
|
if (defaults[@"open"]) {
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
231
|
+
/*
|
232
|
+
* it may be better to use stringByAddingPercentEncodingWithAllowedCharacters instead of stringByAddingPercentEscapesUsingEncoding,
|
233
|
+
* but stringByAddingPercentEncodingWithAllowedCharacters is only available on OS X 10.9 or higher.
|
234
|
+
*/
|
235
|
+
NSString *encodedURL = [defaults[@"open"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
236
|
+
NSURL *url = [NSURL URLWithString:defaults[@"open"]];
|
237
|
+
NSString *fragment = [url fragment];
|
238
|
+
if (fragment) {
|
239
|
+
options[@"open"] = [self decodeFragmentInURL:encodedURL fragment:fragment];
|
240
|
+
} else {
|
241
|
+
options[@"open"] = encodedURL;
|
242
|
+
}
|
208
243
|
}
|
209
244
|
|
245
|
+
options[@"uuid"] = [NSString stringWithFormat:@"%ld", self.hash];
|
246
|
+
|
210
247
|
[self deliverNotificationWithTitle:defaults[@"title"] ?: @"Terminal"
|
211
248
|
subtitle:subtitle
|
212
249
|
message:message
|
@@ -234,14 +271,14 @@ isMavericks()
|
|
234
271
|
*/
|
235
272
|
- (NSString*)decodeFragmentInURL:(NSString *) encodedURL fragment:(NSString *) framgent
|
236
273
|
{
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
274
|
+
NSString *beforeStr = [@"%23" stringByAppendingString:framgent];
|
275
|
+
NSString *afterStr = [@"#" stringByAppendingString:framgent];
|
276
|
+
NSString *decodedURL = [encodedURL stringByReplacingOccurrencesOfString:beforeStr withString:afterStr];
|
277
|
+
return decodedURL;
|
241
278
|
}
|
242
279
|
|
243
280
|
- (void)deliverNotificationWithTitle:(NSString *)title
|
244
|
-
|
281
|
+
subtitle:(NSString *)subtitle
|
245
282
|
message:(NSString *)message
|
246
283
|
options:(NSDictionary *)options
|
247
284
|
sound:(NSString *)sound;
|
@@ -269,12 +306,43 @@ isMavericks()
|
|
269
306
|
}
|
270
307
|
|
271
308
|
if (sound != nil) {
|
272
|
-
userNotification.soundName = [sound isEqualToString: @"default"] ? NSUserNotificationDefaultSoundName : sound
|
309
|
+
userNotification.soundName = [sound isEqualToString: @"default"] ? NSUserNotificationDefaultSoundName : sound;
|
310
|
+
}
|
311
|
+
|
312
|
+
// Actions
|
313
|
+
if (options[@"actions"]){
|
314
|
+
[userNotification setValue:@YES forKey:@"_showsButtons"];
|
315
|
+
NSArray *myActions = [options[@"actions"] componentsSeparatedByString:@","];
|
316
|
+
if (myActions.count > 1) {
|
317
|
+
[userNotification setValue:@YES forKey:@"_alwaysShowAlternateActionMenu"];
|
318
|
+
[userNotification setValue:myActions forKey:@"_alternateActionButtonTitles"];
|
319
|
+
|
320
|
+
//Main Actions Title
|
321
|
+
if(options[@"dropdownLabel"]){
|
322
|
+
userNotification.actionButtonTitle = options[@"dropdownLabel"];
|
323
|
+
userNotification.hasActionButton = true;
|
324
|
+
}
|
325
|
+
}else{
|
326
|
+
userNotification.actionButtonTitle = options[@"actions"];
|
327
|
+
}
|
328
|
+
}else if (options[@"reply"]) {
|
329
|
+
[userNotification setValue:@YES forKey:@"_showsButtons"];
|
330
|
+
userNotification.hasReplyButton = 1;
|
331
|
+
userNotification.responsePlaceholder = options[@"reply"];
|
332
|
+
}
|
333
|
+
|
334
|
+
// Close button
|
335
|
+
if(options[@"closeLabel"]){
|
336
|
+
userNotification.otherButtonTitle = options[@"closeLabel"];
|
337
|
+
}
|
338
|
+
|
339
|
+
if (sound != nil) {
|
340
|
+
userNotification.soundName = [sound isEqualToString: @"default"] ? NSUserNotificationDefaultSoundName : sound;
|
273
341
|
}
|
274
342
|
|
275
343
|
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
|
276
344
|
center.delegate = self;
|
277
|
-
[center
|
345
|
+
[center deliverNotification:userNotification];
|
278
346
|
}
|
279
347
|
|
280
348
|
- (void)removeNotificationWithGroupID:(NSString *)groupID;
|
@@ -282,38 +350,11 @@ isMavericks()
|
|
282
350
|
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
|
283
351
|
for (NSUserNotification *userNotification in center.deliveredNotifications) {
|
284
352
|
if ([@"ALL" isEqualToString:groupID] || [userNotification.userInfo[@"groupID"] isEqualToString:groupID]) {
|
285
|
-
NSString *deliveredAt = [userNotification.actualDeliveryDate description];
|
286
|
-
printf("* Removing previously sent notification, which was sent on: %s\n", [deliveredAt UTF8String]);
|
287
353
|
[center removeDeliveredNotification:userNotification];
|
288
354
|
}
|
289
355
|
}
|
290
356
|
}
|
291
357
|
|
292
|
-
- (void)listNotificationWithGroupID:(NSString *)listGroupID;
|
293
|
-
{
|
294
|
-
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
|
295
|
-
|
296
|
-
NSMutableArray *lines = [NSMutableArray array];
|
297
|
-
for (NSUserNotification *userNotification in center.deliveredNotifications) {
|
298
|
-
NSString *deliveredgroupID = userNotification.userInfo[@"groupID"];
|
299
|
-
NSString *title = userNotification.title;
|
300
|
-
NSString *subtitle = userNotification.subtitle;
|
301
|
-
NSString *message = userNotification.informativeText;
|
302
|
-
NSString *deliveredAt = [userNotification.actualDeliveryDate description];
|
303
|
-
if ([@"ALL" isEqualToString:listGroupID] || [deliveredgroupID isEqualToString:listGroupID]) {
|
304
|
-
[lines addObject:[NSString stringWithFormat:@"%@\t%@\t%@\t%@\t%@", deliveredgroupID, title, subtitle, message, deliveredAt]];
|
305
|
-
}
|
306
|
-
}
|
307
|
-
|
308
|
-
if (lines.count > 0) {
|
309
|
-
printf("GroupID\tTitle\tSubtitle\tMessage\tDelivered At\n");
|
310
|
-
for (NSString *line in lines) {
|
311
|
-
printf("%s\n", [line UTF8String]);
|
312
|
-
}
|
313
|
-
}
|
314
|
-
}
|
315
|
-
|
316
|
-
|
317
358
|
- (void)userActivatedNotification:(NSUserNotification *)userNotification;
|
318
359
|
{
|
319
360
|
[[NSUserNotificationCenter defaultUserNotificationCenter] removeDeliveredNotification:userNotification];
|
@@ -323,21 +364,9 @@ isMavericks()
|
|
323
364
|
NSString *command = userNotification.userInfo[@"command"];
|
324
365
|
NSString *open = userNotification.userInfo[@"open"];
|
325
366
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
NSLog(@" subtitle: %@", userNotification.subtitle);
|
330
|
-
NSLog(@" message: %@", userNotification.informativeText);
|
331
|
-
NSLog(@"bundle ID: %@", bundleID);
|
332
|
-
NSLog(@" command: %@", command);
|
333
|
-
NSLog(@" open: %@", open);
|
334
|
-
|
335
|
-
BOOL success = YES;
|
336
|
-
if (bundleID) success &= [self activateAppWithBundleID:bundleID];
|
337
|
-
if (command) success &= [self executeShellCommand:command];
|
338
|
-
if (open) success &= [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:open]];
|
339
|
-
|
340
|
-
exit(success ? 0 : 1);
|
367
|
+
if (bundleID) [self activateAppWithBundleID:bundleID];
|
368
|
+
if (command) [self executeShellCommand:command];
|
369
|
+
if (open) [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:open]];
|
341
370
|
}
|
342
371
|
|
343
372
|
- (BOOL)activateAppWithBundleID:(NSString *)bundleID;
|
@@ -377,16 +406,199 @@ isMavericks()
|
|
377
406
|
}
|
378
407
|
|
379
408
|
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
|
380
|
-
shouldPresentNotification:(NSUserNotification *)
|
409
|
+
shouldPresentNotification:(NSUserNotification *)notification;
|
381
410
|
{
|
382
411
|
return YES;
|
383
412
|
}
|
384
413
|
|
385
|
-
// Once the notification is delivered we can exit.
|
414
|
+
// Once the notification is delivered we can exit. (Only if no actions or reply)
|
386
415
|
- (void)userNotificationCenter:(NSUserNotificationCenter *)center
|
387
416
|
didDeliverNotification:(NSUserNotification *)userNotification;
|
388
417
|
{
|
418
|
+
currentNotification = userNotification;
|
419
|
+
|
420
|
+
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
|
421
|
+
^{
|
422
|
+
__block BOOL notificationStillPresent;
|
423
|
+
do {
|
424
|
+
notificationStillPresent = NO;
|
425
|
+
for (NSUserNotification *nox in [[NSUserNotificationCenter defaultUserNotificationCenter] deliveredNotifications]) {
|
426
|
+
if ([nox.userInfo[@"uuid"] isEqualToString:[NSString stringWithFormat:@"%ld", self.hash] ]) notificationStillPresent = YES;
|
427
|
+
}
|
428
|
+
if (notificationStillPresent) [NSThread sleepForTimeInterval:0.20f];
|
429
|
+
} while (notificationStillPresent);
|
430
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
431
|
+
NSDictionary *udict = @{@"activationType" : @"closed", @"activationValue" : userNotification.otherButtonTitle};
|
432
|
+
[self Quit:udict notification:userNotification];
|
433
|
+
exit(0);
|
434
|
+
});
|
435
|
+
});
|
436
|
+
|
437
|
+
if ([userNotification.userInfo[@"timeout"] integerValue] > 0){
|
438
|
+
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
|
439
|
+
^{
|
440
|
+
[NSThread sleepForTimeInterval:[userNotification.userInfo[@"timeout"] integerValue]];
|
441
|
+
[center removeDeliveredNotification:currentNotification];
|
442
|
+
[center removeDeliveredNotification:userNotification];
|
443
|
+
NSDictionary *udict = @{@"activationType" : @"timeout"};
|
444
|
+
[self Quit:udict notification:userNotification];
|
445
|
+
exit(0);
|
446
|
+
|
447
|
+
});
|
448
|
+
}
|
449
|
+
}
|
450
|
+
|
451
|
+
- (void)userNotificationCenter:(NSUserNotificationCenter *)center
|
452
|
+
didActivateNotification:(NSUserNotification *)notification {
|
453
|
+
|
454
|
+
if ([notification.userInfo[@"uuid"] isNotEqualTo:[NSString stringWithFormat:@"%ld", self.hash] ]) {
|
455
|
+
return;
|
456
|
+
};
|
457
|
+
|
458
|
+
unsigned long long additionalActionIndex = ULLONG_MAX;
|
459
|
+
|
460
|
+
NSString* ActionsClicked = @"";
|
461
|
+
switch (notification.activationType) {
|
462
|
+
|
463
|
+
case NSUserNotificationActivationTypeAdditionalActionClicked:
|
464
|
+
case NSUserNotificationActivationTypeActionButtonClicked:
|
465
|
+
if ([[(NSObject*)notification valueForKey:@"_alternateActionButtonTitles"] count] > 1 ){
|
466
|
+
NSNumber *alternateActionIndex = [(NSObject*)notification valueForKey:@"_alternateActionIndex"];
|
467
|
+
additionalActionIndex = [alternateActionIndex unsignedLongLongValue];
|
468
|
+
ActionsClicked = [(NSObject*)notification valueForKey:@"_alternateActionButtonTitles"][additionalActionIndex];
|
469
|
+
|
470
|
+
NSDictionary *udict = @{@"activationType" : @"actionClicked", @"activationValue" : ActionsClicked, @"activationValueIndex" :[NSString stringWithFormat:@"%llu", additionalActionIndex]};
|
471
|
+
[self Quit:udict notification:notification];
|
472
|
+
}else{
|
473
|
+
NSDictionary *udict = @{@"activationType" : @"actionClicked", @"activationValue" : notification.actionButtonTitle};
|
474
|
+
[self Quit:udict notification:notification];
|
475
|
+
}
|
476
|
+
break;
|
477
|
+
|
478
|
+
case NSUserNotificationActivationTypeContentsClicked:
|
479
|
+
[self userActivatedNotification:notification];
|
480
|
+
[self Quit:@{@"activationType" : @"contentsClicked"} notification:notification];
|
481
|
+
break;
|
482
|
+
|
483
|
+
case NSUserNotificationActivationTypeReplied:
|
484
|
+
[self Quit:@{@"activationType" : @"replied",@"activationValue":notification.response.string} notification:notification];
|
485
|
+
break;
|
486
|
+
case NSUserNotificationActivationTypeNone:
|
487
|
+
default:
|
488
|
+
[self Quit:@{@"activationType" : @"none"} notification:notification];
|
489
|
+
break;
|
490
|
+
}
|
491
|
+
|
492
|
+
[center removeDeliveredNotification:notification];
|
493
|
+
[center removeDeliveredNotification:currentNotification];
|
389
494
|
exit(0);
|
390
495
|
}
|
391
496
|
|
497
|
+
- (BOOL)Quit:(NSDictionary *)udict notification:(NSUserNotification *)notification;
|
498
|
+
{
|
499
|
+
if ([notification.userInfo[@"output"] isEqualToString:@"outputEvent"]) {
|
500
|
+
if ([udict[@"activationType"] isEqualToString:@"closed"]) {
|
501
|
+
if ([udict[@"activationValue"] isEqualToString:@""]) {
|
502
|
+
printf("%s", "@CLOSED" );
|
503
|
+
}else{
|
504
|
+
printf("%s", [udict[@"activationValue"] UTF8String] );
|
505
|
+
}
|
506
|
+
} else if ([udict[@"activationType"] isEqualToString:@"timeout"]) {
|
507
|
+
printf("%s", "@TIMEOUT" );
|
508
|
+
} else if ([udict[@"activationType"] isEqualToString:@"contentsClicked"]) {
|
509
|
+
printf("%s", "@CONTENTCLICKED" );
|
510
|
+
} else{
|
511
|
+
if ([udict[@"activationValue"] isEqualToString:@""]) {
|
512
|
+
printf("%s", "@ACTIONCLICKED" );
|
513
|
+
}else{
|
514
|
+
printf("%s", [udict[@"activationValue"] UTF8String] );
|
515
|
+
}
|
516
|
+
}
|
517
|
+
|
518
|
+
return 1;
|
519
|
+
}
|
520
|
+
|
521
|
+
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
522
|
+
dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss Z";
|
523
|
+
|
524
|
+
// Dictionary with several key/value pairs and the above array of arrays
|
525
|
+
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
526
|
+
[dict addEntriesFromDictionary:udict];
|
527
|
+
[dict setValue:[dateFormatter stringFromDate:notification.actualDeliveryDate] forKey:@"deliveredAt"];
|
528
|
+
[dict setValue:[dateFormatter stringFromDate:[NSDate new]] forKey:@"activationAt"];
|
529
|
+
|
530
|
+
NSError *error = nil;
|
531
|
+
NSData *json;
|
532
|
+
|
533
|
+
// Dictionary convertable to JSON ?
|
534
|
+
if ([NSJSONSerialization isValidJSONObject:dict])
|
535
|
+
{
|
536
|
+
// Serialize the dictionary
|
537
|
+
json = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
|
538
|
+
|
539
|
+
// If no errors, let's view the JSON
|
540
|
+
if (json != nil && error == nil)
|
541
|
+
{
|
542
|
+
NSString *jsonString = [[NSString alloc] initWithData:json encoding:NSUTF8StringEncoding];
|
543
|
+
printf("%s", [jsonString cStringUsingEncoding:NSUTF8StringEncoding]);
|
544
|
+
}
|
545
|
+
}
|
546
|
+
|
547
|
+
return 1;
|
548
|
+
}
|
549
|
+
|
550
|
+
- (void)listNotificationWithGroupID:(NSString *)listGroupID;
|
551
|
+
{
|
552
|
+
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
|
553
|
+
|
554
|
+
NSMutableArray *lines = [NSMutableArray array];
|
555
|
+
for (NSUserNotification *userNotification in center.deliveredNotifications) {
|
556
|
+
NSString *deliveredgroupID = userNotification.userInfo[@"groupID"];
|
557
|
+
NSString *title = userNotification.title;
|
558
|
+
NSString *subtitle = userNotification.subtitle;
|
559
|
+
NSString *message = userNotification.informativeText;
|
560
|
+
NSString *deliveredAt = [userNotification.actualDeliveryDate description];
|
561
|
+
|
562
|
+
if ([@"ALL" isEqualToString:listGroupID] || [deliveredgroupID isEqualToString:listGroupID]) {
|
563
|
+
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
564
|
+
[dict setValue:deliveredgroupID forKey:@"GroupID"];
|
565
|
+
[dict setValue:title forKey:@"Title"];
|
566
|
+
[dict setValue:subtitle forKey:@"subtitle"];
|
567
|
+
[dict setValue:message forKey:@"message"];
|
568
|
+
[dict setValue:deliveredAt forKey:@"deliveredAt"];
|
569
|
+
[lines addObject:dict];
|
570
|
+
}
|
571
|
+
}
|
572
|
+
|
573
|
+
if (lines.count > 0) {
|
574
|
+
NSData *json;
|
575
|
+
NSError *error = nil;
|
576
|
+
// Dictionary convertable to JSON ?
|
577
|
+
if ([NSJSONSerialization isValidJSONObject:lines])
|
578
|
+
{
|
579
|
+
// Serialize the dictionary
|
580
|
+
json = [NSJSONSerialization dataWithJSONObject:lines options:NSJSONWritingPrettyPrinted error:&error];
|
581
|
+
|
582
|
+
// If no errors, let's view the JSON
|
583
|
+
if (json != nil && error == nil)
|
584
|
+
{
|
585
|
+
NSString *jsonString = [[NSString alloc] initWithData:json encoding:NSUTF8StringEncoding];
|
586
|
+
printf("%s", [jsonString cStringUsingEncoding:NSUTF8StringEncoding]);
|
587
|
+
}
|
588
|
+
}
|
589
|
+
|
590
|
+
}
|
591
|
+
}
|
592
|
+
|
593
|
+
- (void) bye; {
|
594
|
+
//Look for the notification sent, remove it when found
|
595
|
+
NSString *UUID = currentNotification.userInfo[@"uuid"];
|
596
|
+
for (NSUserNotification *nox in [[NSUserNotificationCenter defaultUserNotificationCenter] deliveredNotifications]) {
|
597
|
+
if ([nox.userInfo[@"uuid"] isEqualToString:UUID ]){
|
598
|
+
[[NSUserNotificationCenter defaultUserNotificationCenter] removeDeliveredNotification:nox];
|
599
|
+
[[NSUserNotificationCenter defaultUserNotificationCenter] removeDeliveredNotification:nox];
|
600
|
+
}
|
601
|
+
}
|
602
|
+
}
|
603
|
+
|
392
604
|
@end
|
@@ -17,20 +17,22 @@
|
|
17
17
|
<key>CFBundlePackageType</key>
|
18
18
|
<string>APPL</string>
|
19
19
|
<key>CFBundleShortVersionString</key>
|
20
|
-
<string>1.
|
20
|
+
<string>1.7.0</string>
|
21
21
|
<key>CFBundleSignature</key>
|
22
22
|
<string>????</string>
|
23
23
|
<key>CFBundleVersion</key>
|
24
|
-
<string>
|
24
|
+
<string>15</string>
|
25
25
|
<key>LSMinimumSystemVersion</key>
|
26
26
|
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
27
27
|
<key>LSUIElement</key>
|
28
28
|
<true/>
|
29
29
|
<key>NSHumanReadableCopyright</key>
|
30
|
-
<string>Copyright © 2012-
|
30
|
+
<string>Copyright © 2012-2016 Eloy Durán, Julien Blanchard. All rights reserved.</string>
|
31
31
|
<key>NSMainNibFile</key>
|
32
32
|
<string>MainMenu</string>
|
33
33
|
<key>NSPrincipalClass</key>
|
34
34
|
<string>NSApplication</string>
|
35
|
+
<key>NSUserNotificationAlertStyle</key>
|
36
|
+
<string>alert</string>
|
35
37
|
</dict>
|
36
38
|
</plist>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<plist version="1.0">
|
4
4
|
<dict>
|
5
5
|
<key>BuildMachineOSBuild</key>
|
6
|
-
<string>
|
6
|
+
<string>16B2333a</string>
|
7
7
|
<key>CFBundleDevelopmentRegion</key>
|
8
8
|
<string>en</string>
|
9
9
|
<key>CFBundleExecutable</key>
|
@@ -19,34 +19,40 @@
|
|
19
19
|
<key>CFBundlePackageType</key>
|
20
20
|
<string>APPL</string>
|
21
21
|
<key>CFBundleShortVersionString</key>
|
22
|
-
<string>1.
|
22
|
+
<string>1.7.0</string>
|
23
23
|
<key>CFBundleSignature</key>
|
24
24
|
<string>????</string>
|
25
|
+
<key>CFBundleSupportedPlatforms</key>
|
26
|
+
<array>
|
27
|
+
<string>MacOSX</string>
|
28
|
+
</array>
|
25
29
|
<key>CFBundleVersion</key>
|
26
|
-
<string>
|
30
|
+
<string>15</string>
|
27
31
|
<key>DTCompiler</key>
|
28
32
|
<string>com.apple.compilers.llvm.clang.1_0</string>
|
29
33
|
<key>DTPlatformBuild</key>
|
30
|
-
<string>
|
34
|
+
<string>8A218a</string>
|
31
35
|
<key>DTPlatformVersion</key>
|
32
36
|
<string>GM</string>
|
33
37
|
<key>DTSDKBuild</key>
|
34
|
-
<string>
|
38
|
+
<string>16A300</string>
|
35
39
|
<key>DTSDKName</key>
|
36
|
-
<string>macosx10.
|
40
|
+
<string>macosx10.12</string>
|
37
41
|
<key>DTXcode</key>
|
38
|
-
<string>
|
42
|
+
<string>0800</string>
|
39
43
|
<key>DTXcodeBuild</key>
|
40
|
-
<string>
|
44
|
+
<string>8A218a</string>
|
41
45
|
<key>LSMinimumSystemVersion</key>
|
42
46
|
<string>10.8</string>
|
43
47
|
<key>LSUIElement</key>
|
44
48
|
<true/>
|
45
49
|
<key>NSHumanReadableCopyright</key>
|
46
|
-
<string>Copyright © 2012-
|
50
|
+
<string>Copyright © 2012-2016 Eloy Durán, Julien Blanchard. All rights reserved.</string>
|
47
51
|
<key>NSMainNibFile</key>
|
48
52
|
<string>MainMenu</string>
|
49
53
|
<key>NSPrincipalClass</key>
|
50
54
|
<string>NSApplication</string>
|
55
|
+
<key>NSUserNotificationAlertStyle</key>
|
56
|
+
<string>alert</string>
|
51
57
|
</dict>
|
52
58
|
</plist>
|
Binary file
|
data/vendor/terminal-notifier/terminal-notifier.app/Contents/Resources/en.lproj/MainMenu.nib
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal-notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Duran
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.5.1
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Send User Notifications on Mac OS X 10.8 or higher.
|