terminal-notifier 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -25,6 +25,8 @@ TerminalNotifier.notify('Hello World', :activate => 'com.apple.Safari')
25
25
  TerminalNotifier.notify('Hello World', :open => 'http://twitter.com/alloy')
26
26
  TerminalNotifier.notify('Hello World', :execute => 'say "OMG"')
27
27
  TerminalNotifier.notify('Hello World', :group => Process.pid)
28
+ TerminalNotifier.notify('Hello World', :sender => 'com.apple.Safari')
29
+ TerminalNotifier.notify('Hello World', :sound => 'default')
28
30
 
29
31
  TerminalNotifier.remove(Process.pid)
30
32
 
@@ -6,4 +6,8 @@ end
6
6
 
7
7
  require 'terminal-notifier'
8
8
 
9
+ if !ARGV.include?("-message") && !STDIN.tty?
10
+ ARGV.push(*["-message", STDIN.read.chomp])
11
+ end
12
+
9
13
  exec TerminalNotifier::BIN_PATH, *ARGV
@@ -1,21 +1,18 @@
1
+ require 'shellwords'
2
+
1
3
  module TerminalNotifier
2
4
  BIN_PATH = File.expand_path('../../vendor/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier', __FILE__)
3
5
 
6
+ class UnsupportedPlatformError < StandardError; end
4
7
  # Returns wether or not the current platform is Mac OS X 10.8, or higher.
5
8
  def self.available?
6
- if @available.nil?
7
- @available = `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
8
- end
9
- @available
9
+ @available ||= `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
10
10
  end
11
11
 
12
12
  def self.execute(verbose, options)
13
13
  if available?
14
- command = [BIN_PATH, *options.map { |k,v| ["-#{k}", v.to_s] }.flatten]
15
- if RUBY_VERSION < '1.9'
16
- require 'shellwords'
17
- command = Shellwords.shelljoin(command)
18
- end
14
+ command = [BIN_PATH, *options.map { |k,v| v = v.to_s; ["-#{k}", "#{Shellwords.escape(v[0,1])}#{v[1..-1]}"] }.flatten]
15
+ command = Shellwords.join(command) if RUBY_VERSION < '1.9'
19
16
  result = ''
20
17
  IO.popen(command) do |stdout|
21
18
  output = stdout.read
@@ -24,14 +21,14 @@ module TerminalNotifier
24
21
  end
25
22
  result
26
23
  else
27
- raise "terminal-notifier is only supported on Mac OS X 10.8, or higher."
24
+ raise UnsupportedPlatformError, "terminal-notifier is only supported on Mac OS X 10.8, or higher."
28
25
  end
29
26
  end
30
27
 
31
28
  # Sends a User Notification and returns wether or not it was a success.
32
29
  #
33
- # The available options are `:title`, `:group`, `:activate`, `:open`, and
34
- # `:execute`. For a description of each option see:
30
+ # The available options are `:title`, `:group`, `:activate`, `:open`,
31
+ # `:execute`, `:sender`, and `:sound`. For a description of each option see:
35
32
  #
36
33
  # https://github.com/alloy/terminal-notifier/blob/master/README.markdown
37
34
  #
@@ -43,6 +40,8 @@ module TerminalNotifier
43
40
  # TerminalNotifier.notify('Hello World', :activate => 'com.apple.Safari')
44
41
  # TerminalNotifier.notify('Hello World', :open => 'http://twitter.com/alloy')
45
42
  # TerminalNotifier.notify('Hello World', :execute => 'say "OMG"')
43
+ # TerminalNotifier.notify('Hello World', :sender => 'com.apple.Safari')
44
+ # TerminalNotifier.notify('Hello World', :sound => 'default')
46
45
  #
47
46
  # Raises if not supported on the current platform.
48
47
  def notify(message, options = {}, verbose = false)
@@ -1,24 +1,26 @@
1
1
  # terminal-notifier
2
2
 
3
3
  terminal-notifier is a command-line tool to send Mac OS X User Notifications,
4
- which are available in Mac OS X 10.8.
4
+ which are available in Mac OS X 10.8 and higher.
5
5
 
6
- It is currently packaged as an application bundle, because `NSUserNotification`
7
- does not work from a ‘Foundation tool’. [radar://11956694](radar://11956694)
8
6
 
9
- The Notification Center _always_ uses the application’s own icon, there’s
10
- currently no way to specify a custom icon for a notification. The only way to
11
- use this tool with your own icon is to include a build of terminal-notifier
12
- with your icon instead.
7
+ ## Caveats
13
8
 
14
- This tool will be used by [Kicker](https://github.com/alloy/kicker) to show the
15
- status of commands which are executed due to filesystem changes. (v3.0.0)
9
+ * The Notification Center _always_ uses the application’s own icon, there’s
10
+ currently no way to specify a custom icon for a notification. The only way to
11
+ use this tool with your own icon is to use the `-sender` option or include a
12
+ build of terminal-notifier with your icon and bundle identifier instead.
13
+
14
+ However, you _can_ use unicode symbols and emojis. See the examples.
15
+
16
+ * It is currently packaged as an application bundle, because `NSUserNotification`
17
+ does not work from a ‘Foundation tool’. [radar://11956694](radar://11956694)
16
18
 
17
19
 
18
20
  ## Download
19
21
 
20
- Prebuilt binaries, which are code-signed and ready to use, are available from
21
- the [downloads section](https://github.com/alloy/terminal-notifier/downloads).
22
+ Prebuilt binaries are available from the
23
+ [releases section](https://github.com/alloy/terminal-notifier/releases).
22
24
 
23
25
  Or if you want to use this from
24
26
  [Ruby](https://github.com/alloy/terminal-notifier/tree/master/Ruby), you can
@@ -47,6 +49,14 @@ $ terminal-notifier -[message|group|list] [VALUE|ID|ID] [options]
47
49
 
48
50
  This will obviously be a bit slower than using the tool without the wrapper.
49
51
 
52
+ Some examples are:
53
+
54
+ ```
55
+ $ echo 'Piped Message Data!' | terminal-notifier -sound default
56
+ $ terminal-notifier -title '💰' -message 'Check your Apple stock!' -open 'http://finance.yahoo.com/q?s=AAPL'
57
+ $ terminal-notifier -group 'address-book-sync' -title 'Address Book Sync' -subtitle 'Finished' -message 'Imported 42 contacts.' -activate 'com.apple.AddressBook'
58
+ ```
59
+
50
60
 
51
61
  #### Options
52
62
 
@@ -59,6 +69,9 @@ option or the `-list` option.
59
69
 
60
70
  The message body of the notification.
61
71
 
72
+ Note that if this option is omitted and data is piped to the application, that
73
+ data will be used instead.
74
+
62
75
  -------------------------------------------------------------------------------
63
76
 
64
77
  `-title VALUE`
@@ -120,6 +133,15 @@ Examples are:
120
133
 
121
134
  -------------------------------------------------------------------------------
122
135
 
136
+ `-sender ID`
137
+
138
+ Specifying this will make it appear as if the notification was send by that
139
+ application instead, including using its icon.
140
+
141
+ For information on the `ID` see the `-activate` option.
142
+
143
+ -------------------------------------------------------------------------------
144
+
123
145
  `-open URL`
124
146
 
125
147
  Specifies a resource to be opened when the user clicks the notification. This
@@ -138,7 +160,7 @@ All the works are available under the MIT license. **Except** for
138
160
  ‘Terminal.icns’, which is a copy of Apple’s Terminal.app icon and as such is
139
161
  copyright of Apple.
140
162
 
141
- Copyright (C) 2012 Eloy Durán <eloy.de.enige@gmail.com>
163
+ Copyright (C) 2012-2013 Eloy Durán <eloy.de.enige@gmail.com>
142
164
 
143
165
  Permission is hereby granted, free of charge, to any person obtaining a copy of
144
166
  this software and associated documentation files (the "Software"), to deal in
@@ -3,7 +3,7 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>BuildMachineOSBuild</key>
6
- <string>12A269</string>
6
+ <string>12E55</string>
7
7
  <key>CFBundleDevelopmentRegion</key>
8
8
  <string>en</string>
9
9
  <key>CFBundleExecutable</key>
@@ -19,31 +19,31 @@
19
19
  <key>CFBundlePackageType</key>
20
20
  <string>APPL</string>
21
21
  <key>CFBundleShortVersionString</key>
22
- <string>1.4.2</string>
22
+ <string>1.5.0</string>
23
23
  <key>CFBundleSignature</key>
24
24
  <string>????</string>
25
25
  <key>CFBundleVersion</key>
26
- <string>7</string>
26
+ <string>8</string>
27
27
  <key>DTCompiler</key>
28
- <string></string>
28
+ <string>com.apple.compilers.llvm.clang.1_0</string>
29
29
  <key>DTPlatformBuild</key>
30
- <string>4F243</string>
30
+ <string>5A11365x</string>
31
31
  <key>DTPlatformVersion</key>
32
32
  <string>GM</string>
33
33
  <key>DTSDKBuild</key>
34
- <string>12A264</string>
34
+ <string>13A538c</string>
35
35
  <key>DTSDKName</key>
36
- <string>macosx10.8</string>
36
+ <string>macosx10.9</string>
37
37
  <key>DTXcode</key>
38
- <string>0440</string>
38
+ <string>0500</string>
39
39
  <key>DTXcodeBuild</key>
40
- <string>4F243</string>
40
+ <string>5A11365x</string>
41
41
  <key>LSMinimumSystemVersion</key>
42
42
  <string>10.8</string>
43
43
  <key>LSUIElement</key>
44
44
  <true/>
45
45
  <key>NSHumanReadableCopyright</key>
46
- <string>Copyright © 2012 Eloy Durán. All rights reserved.</string>
46
+ <string>Copyright © 2012 Eloy Durán. All rights reserved.</string>
47
47
  <key>NSMainNibFile</key>
48
48
  <string>MainMenu</string>
49
49
  <key>NSPrincipalClass</key>
metadata CHANGED
@@ -1,77 +1,77 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: terminal-notifier
3
- version: !ruby/object:Gem::Version
4
- version: 1.4.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 5
9
+ - 0
10
+ version: 1.5.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Eloy Duran
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-08-10 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-08-24 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: bacon
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: mocha
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
38
32
  type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: mocha
39
36
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
41
38
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: mocha-on-bacon
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
54
46
  type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: mocha-on-bacon
55
50
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
57
52
  none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :development
61
+ version_requirements: *id003
62
62
  description:
63
- email:
63
+ email:
64
64
  - eloy.de.enige@gmail.com
65
- executables:
65
+ executables:
66
66
  - terminal-notifier
67
67
  extensions: []
68
- extra_rdoc_files:
68
+
69
+ extra_rdoc_files:
69
70
  - README.markdown
70
- files:
71
+ files:
71
72
  - bin/terminal-notifier
72
73
  - lib/terminal-notifier.rb
73
74
  - vendor/terminal-notifier/README.markdown
74
- - vendor/terminal-notifier/terminal-notifier.app/Contents/_CodeSignature/CodeResources
75
75
  - vendor/terminal-notifier/terminal-notifier.app/Contents/Info.plist
76
76
  - vendor/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier
77
77
  - vendor/terminal-notifier/terminal-notifier.app/Contents/PkgInfo
@@ -82,27 +82,37 @@ files:
82
82
  - README.markdown
83
83
  homepage: https://github.com/alloy/terminal-notifier
84
84
  licenses: []
85
+
85
86
  post_install_message:
86
87
  rdoc_options: []
87
- require_paths:
88
+
89
+ require_paths:
88
90
  - lib
89
- required_ruby_version: !ruby/object:Gem::Requirement
91
+ required_ruby_version: !ruby/object:Gem::Requirement
90
92
  none: false
91
- requirements:
92
- - - ! '>='
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
- required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
101
  none: false
97
- requirements:
98
- - - ! '>='
99
- - !ruby/object:Gem::Version
100
- version: '0'
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
101
109
  requirements: []
110
+
102
111
  rubyforge_project:
103
- rubygems_version: 1.8.23
112
+ rubygems_version: 1.8.24
104
113
  signing_key:
105
114
  specification_version: 3
106
- summary: Send User Notifications on Mac OS X 10.8.
115
+ summary: Send User Notifications on Mac OS X 10.8 or higher.
107
116
  test_files: []
117
+
108
118
  has_rdoc:
@@ -1,61 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>files</key>
6
- <dict>
7
- <key>Resources/Terminal.icns</key>
8
- <data>
9
- Oq9GtJM1DqcGF1JCHiEgb0hoN6I=
10
- </data>
11
- <key>Resources/en.lproj/Credits.rtf</key>
12
- <dict>
13
- <key>hash</key>
14
- <data>
15
- YKJIFIsxneJuNkJNJQIcJIjiPOg=
16
- </data>
17
- <key>optional</key>
18
- <true/>
19
- </dict>
20
- <key>Resources/en.lproj/InfoPlist.strings</key>
21
- <dict>
22
- <key>hash</key>
23
- <data>
24
- MiLKDDnrUKr4EmuvhS5VQwxHGK8=
25
- </data>
26
- <key>optional</key>
27
- <true/>
28
- </dict>
29
- <key>Resources/en.lproj/MainMenu.nib</key>
30
- <dict>
31
- <key>hash</key>
32
- <data>
33
- N1QqAM17vgDk7XNtv27koaE4IhE=
34
- </data>
35
- <key>optional</key>
36
- <true/>
37
- </dict>
38
- </dict>
39
- <key>rules</key>
40
- <dict>
41
- <key>^Resources/</key>
42
- <true/>
43
- <key>^Resources/.*\.lproj/</key>
44
- <dict>
45
- <key>optional</key>
46
- <true/>
47
- <key>weight</key>
48
- <real>1000</real>
49
- </dict>
50
- <key>^Resources/.*\.lproj/locversion.plist$</key>
51
- <dict>
52
- <key>omit</key>
53
- <true/>
54
- <key>weight</key>
55
- <real>1100</real>
56
- </dict>
57
- <key>^version.plist$</key>
58
- <true/>
59
- </dict>
60
- </dict>
61
- </plist>