diff --git a/README.markdown b/README.markdown index aa4e94c..0faf7fc 100644 --- a/README.markdown +++ b/README.markdown @@ -1,21 +1,11 @@ # terminal-notifier terminal-notifier is a command-line tool to send macOS User Notifications, -which are available on macOS 10.8 and higher. +which are available on macOS 10.10 and higher. ## Caveats -* On macOS 10.8, the `-appIcon` and `-contentImage` options do nothing. - This is because Notification Center on 10.8 _always_ uses the application’s own icon. - - You can do one of the following to work around this limitation on 10.8: - - Use the `-sender` option to “fake it” (see below) - - Include a build of terminal-notifier with your icon **and a different bundle identifier**. - (If you don’t change the bundle identifier, launch services uses a cached version of the icon.) - - However, you _can_ use unicode symbols and emojis! See the examples. - * It is currently packaged as an application bundle, because `NSUserNotification` does not work from a ‘Foundation tool’. [radar://11956694](radar://11956694) diff --git a/Ruby/README.markdown b/Ruby/README.markdown index d8e16c8..bdb8d73 100644 --- a/Ruby/README.markdown +++ b/Ruby/README.markdown @@ -2,7 +2,7 @@ A simple Ruby wrapper around the [`terminal-notifier`][HOMEPAGE] command-line tool, which allows you to send User Notifications to the Notification Center on -Mac OS X 10.8, or higher. +macOS 10.10, or higher. ## Installation diff --git a/Ruby/lib/terminal-notifier.rb b/Ruby/lib/terminal-notifier.rb index d42f02d..6d6f683 100644 --- a/Ruby/lib/terminal-notifier.rb +++ b/Ruby/lib/terminal-notifier.rb @@ -5,9 +5,9 @@ module TerminalNotifier BIN_PATH = File.expand_path('../../vendor/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier', __FILE__) class UnsupportedPlatformError < StandardError; end - # Returns wether or not the current platform is Mac OS X 10.8, or higher. + # Returns wether or not the current platform is macOS 10.10, or higher. def self.available? - @available ||= (/darwin|mac os/ =~ RbConfig::CONFIG['host_os']) && Gem::Version.new(version) > Gem::Version.new('10.8') + @available ||= (/darwin|mac os/ =~ RbConfig::CONFIG['host_os']) && Gem::Version.new(version) > Gem::Version.new('10.10') end def self.version @@ -26,19 +26,19 @@ def self.execute(verbose, options) end result else - STDERR.print "terminal-notifier is only supported on Mac OS X 10.8, or higher." + STDERR.print "terminal-notifier is only supported on macOS 10.10, or higher." end end # Cleans up the result of a notification, making it easier to work it - # + # # The result of a notification is downcased, then groups of 1 or more # non-word characters are replaced with an underscore, before being - # symbolised. + # symbolised. # - # If the reply option was given, then instead of going through the + # If the reply option was given, then instead of going through the # above process, the result is returned with no changes as a string. - # + # # If the always_string param is set to true, a the result is returned # with no changes as a string, like above. # diff --git a/Ruby/terminal-notifier.gemspec b/Ruby/terminal-notifier.gemspec index 3dae8b8..2be5d1a 100644 --- a/Ruby/terminal-notifier.gemspec +++ b/Ruby/terminal-notifier.gemspec @@ -8,7 +8,7 @@ version = File.read(plist).match(%r{(\d+\.\d+\.\d+)})[1] Gem::Specification.new do |gem| gem.name = "terminal-notifier" gem.version = version - gem.summary = 'Send User Notifications on Mac OS X 10.8 or higher.' + gem.summary = 'Send User Notifications on macOS 10.10 or higher.' gem.authors = ["Eloy Duran", "Julien Blanchard"] gem.email = ["eloy.de.enige@gmail.com", "julien@sideburns.eu"] gem.homepage = 'https://github.com/julienXX/terminal-notifier' diff --git a/Terminal Notifier/AppDelegate.m b/Terminal Notifier/AppDelegate.m index 11a33a2..1d81796 100644 --- a/Terminal Notifier/AppDelegate.m +++ b/Terminal Notifier/AppDelegate.m @@ -2,12 +2,11 @@ #import #import -NSString * const TerminalNotifierBundleID = @"nl.superalloy.oss.terminal-notifier"; +NSString * const TerminalNotifierBundleID = @"fr.julienxx.oss.terminal-notifier"; NSString * const NotificationCenterUIBundleID = @"com.apple.notificationcenterui"; // Set OS Params -#define NSAppKitVersionNumber10_8 1187 -#define NSAppKitVersionNumber10_9 1265 +#define NSAppKitVersionNumber10_10 1343 #define contains(str1, str2) ([str1 rangeOfString: str2 ].location != NSNotFound) @@ -40,18 +39,6 @@ - (NSString *)__bundleIdentifier; return NO; } -static BOOL -isMavericks() -{ - if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_8) { - /* On a 10.8 - 10.8.x system */ - return NO; - } else { - /* 10.9 or later system */ - return YES; - } -} - @implementation NSUserDefaults (SubscriptAndUnescape) - (id)objectForKeyedSubscript:(id)key; { @@ -72,14 +59,7 @@ +(void)initializeUserDefaults // initialize the dictionary with default values depending on OS level NSDictionary *appDefaults; - - if (isMavericks()) { - //10.9 - appDefaults = @{@"sender": @"com.apple.Terminal"}; - } else { - //10.8 - appDefaults = @{@"": @"message"}; - } + appDefaults = @{@"sender": @"com.apple.Terminal"}; // and set them appropriately [defaults registerDefaults:appDefaults]; @@ -89,7 +69,7 @@ - (void)printHelpBanner; { const char *appName = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"] UTF8String]; const char *appVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] UTF8String]; - printf("%s (%s) is a command-line tool to send OS X User Notifications.\n" \ + printf("%s (%s) is a command-line tool to send macOS User Notifications.\n" \ "\n" \ "Usage: %s -[message|list|remove] [VALUE|ID|ID] [options]\n" \ "\n" \ @@ -147,7 +127,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification; [self printHelpBanner]; exit(0); } - + if ([[[NSProcessInfo processInfo] arguments] indexOfObject:@"-version"] != NSNotFound) { [self printVersion]; exit(0); @@ -208,7 +188,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification; if (defaults[@"execute"]) options[@"command"] = defaults[@"execute"]; if (defaults[@"appIcon"]) options[@"appIcon"] = defaults[@"appIcon"]; if (defaults[@"contentImage"]) options[@"contentImage"] = defaults[@"contentImage"]; - + if (defaults[@"open"]) { NSURL *url = [NSURL URLWithString:defaults[@"open"]]; if ((url && url.scheme && url.host) || [url isFileURL]) { @@ -218,7 +198,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification; exit(1); } } - + if([[[NSProcessInfo processInfo] arguments] containsObject:@"-ignoreDnD"] == true) { options[@"ignoreDnD"] = @YES; } @@ -271,23 +251,20 @@ - (void)deliverNotificationWithTitle:(NSString *)title userNotification.informativeText = message; userNotification.userInfo = options; - if(isMavericks()){ - // Mavericks options - if(options[@"appIcon"]){ - // replacement app icon - [userNotification setValue:[self getImageFromURL:options[@"appIcon"]] forKey:@"_identityImage"]; - [userNotification setValue:@(false) forKey:@"_identityImageHasBorder"]; - } - if(options[@"contentImage"]){ - // content image - userNotification.contentImage = [self getImageFromURL:options[@"contentImage"]]; - } + if(options[@"appIcon"]){ + // replacement app icon + [userNotification setValue:[self getImageFromURL:options[@"appIcon"]] forKey:@"_identityImage"]; + [userNotification setValue:@(false) forKey:@"_identityImageHasBorder"]; + } + if(options[@"contentImage"]){ + // content image + userNotification.contentImage = [self getImageFromURL:options[@"contentImage"]]; } if (sound != nil) { userNotification.soundName = [sound isEqualToString: @"default"] ? NSUserNotificationDefaultSoundName : sound ; } - + if(options[@"ignoreDnD"]){ [userNotification setValue:@YES forKey:@"_ignoresDoNotDisturb"]; } diff --git a/Terminal Notifier/Terminal Notifier-Info.plist b/Terminal Notifier/Terminal Notifier-Info.plist index 2b11851..dd972d6 100644 --- a/Terminal Notifier/Terminal Notifier-Info.plist +++ b/Terminal Notifier/Terminal Notifier-Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile Terminal CFBundleIdentifier - nl.superalloy.oss.${PRODUCT_NAME:rfc1034identifier} + fr.julienxx.oss.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion 6.0 CFBundleName