diff options
| author | Gabriel Handford | 2016-05-16 15:09:40 -0700 |
|---|---|---|
| committer | Gabriel Handford | 2016-05-16 15:09:40 -0700 |
| commit | abdbf886c96d0390fd582fd7a4e9e2924c9ed740 (patch) | |
| tree | eaa10364e46907c8b888d6266646cae63c780049 | |
| parent | 1a97dd20fd0dd0bc898364570b516d729fbcd869 (diff) | |
| download | go-notifier-abdbf886c96d0390fd582fd7a4e9e2924c9ed740.tar.bz2 | |
Specify default timeout
| -rw-r--r-- | notifier/notifier.go | 2 | ||||
| -rw-r--r-- | notifier_darwin.go | 5 | ||||
| -rw-r--r-- | notifier_darwin.m | 4 |
3 files changed, 6 insertions, 5 deletions
diff --git a/notifier/notifier.go b/notifier/notifier.go index 169a987..989580e 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -21,7 +21,7 @@ func main() { // OS X kingpin.Flag("action", "Actions (for OS X)").StringsVar(¬ification.Actions) - kingpin.Flag("timeout", "Timeout in seconds (for OS X)").Float64Var(¬ification.Timeout) + kingpin.Flag("timeout", "Timeout in seconds (for OS X)").Default("5").Float64Var(¬ification.Timeout) kingpin.Flag("bundle-id", "Bundle identifier (for OS X)").StringVar(¬ification.BundleID) // Windows diff --git a/notifier_darwin.go b/notifier_darwin.go index 4287bd5..d69a89c 100644 --- a/notifier_darwin.go +++ b/notifier_darwin.go @@ -7,7 +7,7 @@ package notifier #cgo CFLAGS: -x objective-c #cgo LDFLAGS: -framework Cocoa -sectcreate __TEXT __info_plist Info.plist #import <Cocoa/Cocoa.h> -extern CFStringRef deliverNotification(CFStringRef title, CFStringRef subtitle, CFStringRef message, CFStringRef appIconURLString, CFArrayRef actions, CFStringRef groupID, CFStringRef bundleID, NSTimeInterval timeout); +extern CFStringRef deliverNotification(CFStringRef title, CFStringRef subtitle, CFStringRef message, CFStringRef appIconURLString, CFArrayRef actions, CFStringRef groupID, CFStringRef bundleID, NSTimeInterval timeout, bool debug); */ import "C" import "fmt" @@ -54,7 +54,8 @@ func (n darwinNotifier) DeliverNotification(notification Notification) error { actionsRef := StringsToCFArray(notification.Actions) defer Release(C.CFTypeRef(actionsRef)) - C.deliverNotification(titleRef, nil, messageRef, appIconURLStringRef, actionsRef, bundleIDRef, nil, C.NSTimeInterval(notification.Timeout)) + C.deliverNotification(titleRef, nil, messageRef, appIconURLStringRef, actionsRef, + bundleIDRef, nil, C.NSTimeInterval(notification.Timeout), false) return nil } diff --git a/notifier_darwin.m b/notifier_darwin.m index 6e4c5ac..1baf885 100644 --- a/notifier_darwin.m +++ b/notifier_darwin.m @@ -33,7 +33,7 @@ static BOOL installFakeBundleIdentifierHook() { @end CFStringRef deliverNotification(CFStringRef titleRef, CFStringRef subtitleRef, CFStringRef messageRef, CFStringRef appIconURLStringRef, - CFArrayRef actionsRef, CFStringRef bundleIDRef, CFStringRef groupIDRef, NSTimeInterval timeout) { + CFArrayRef actionsRef, CFStringRef bundleIDRef, CFStringRef groupIDRef, NSTimeInterval timeout, bool debug) { if (bundleIDRef) { _fakeBundleIdentifier = (NSString *)bundleIDRef; @@ -71,7 +71,7 @@ CFStringRef deliverNotification(CFStringRef titleRef, CFStringRef subtitleRef, C } NSUserNotificationCenter *userNotificationCenter = [NSUserNotificationCenter defaultUserNotificationCenter]; - //NSLog(@"Deliver: %@", userNotification); + if (debug) NSLog(@"Deliver: %@", userNotification); NotificationDelegate *delegate = [[NotificationDelegate alloc] init]; delegate.timeout = timeout; delegate.uuid = uuid; |
