Post-It
Sticky Notifications is a Mac Application developed by the brilliant Matt Gemmell. It allows you to create post-it note style reminders into Notification Center (Mountain Lion or later) or Growl.
Post-It is a simple utility that uses Sticky Notifications to post messages to Notification Center on Mac OS X. You can now easily send yourself notifications from command-line or your own scripts and applications.
Important: This utility will only function if you have Sticky Notifications.app v1.0.4+ installed.
Installation
Add this line to your application's Gemfile:
gem 'post-it'
And then execute:
$ bundle
Or install it yourself as:
$ gem install post-it
Usage
Shell or Terminal
Usage: post-it [options] message Options: --version Show help/version info --prepare Prepare the post-it and open it inside Sticky Notifications.app -t, --title TITLE The title of the notification (default: Post It) -s, --subtitle SUBTITLE The subtitle of the notification Arguments: message The notification message that will be displayed in Notification Center.
Post a simple message:
$ post-it "My Message"
Post with custom titles:
$ post-it -t "My Title" -s "My Subtitle" "My Message"
Prepare a message in SN:
$ post-it --prepare -t "My Title" -s "My Subtitle" "My Message"
Ruby Class
The post-it
terminal command simply uses the PostIt::Notification class in order to send messages to Sticky Notifications. You can do the same thing form your ruby scripts.
Quick and dirty notifications:
post_it = PostIt::Notification.new()
post_it.send("My Message")
You can define default values for both the title
and the subtitle
when you create the post-it object. These options are passed as a hash.
post_it = PostIt::Notification.new({:title => "My Title", :subtitle => "My Subtitle"})
You can override the default titles when you are sending the notification:
post_it.send(message,{:title => "My Title",:subtitle => "Post-It"})
You can prepare a notification to be posted by having it open inside a SN window:
post_it.prepare(message,{:title => "Optional"})
Its probably a good idea to check for errors when you are using Post-It. Exceptions will be raised in two scenarios:
- If the Sticky Notifications.app is not found in the
/Applications
folder. - If an error occurs while sending the notifications via the SN URL scheme.
Example:
begin
post_it = PostIt::Notification.new()
post_it.send(message)
rescue Exception => e
# There was an error
puts e.message
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request