Giter Club home page Giter Club logo

notifier's Introduction

Notifier

Gem Gem

Send system notifications on several platforms with a simple and unified API. Currently supports:

  • terminal-notifier (Notification Center wrapper for Mac OS X)
  • HUD
  • Kdialog (Linux/KDE)
  • Knotify (Linux/KDE)
  • OSD Cat (Linux)
  • Libnotify (Linux)
  • Snarl (Windows)

Installation

gem install notifier

Mac OS X

terminal-notifier

terminal-notifier also supports two additional flags:

  • subtitle
  • sound

See terminal-notifier's help for additional information.

hud

Linux

If you're a linux guy, you can choose one of these methods:

  • Install libnotify-bin and its dependencies: sudo aptitude install libnotify-bin
  • Install xosd-bin: sudo aptitude install xosd-bin
  • KDE users don't need to install anything: Test Notifier will use +knotify+ or +kdialog+.

Windows

Usage

Notifier will try to detect which notifiers are available in your system. So you can just send a message:

Notifier.notify(
  image: "image.png",
  title: "Testing Notifier",
  message: "Sending an important message!"
)

Not all notifiers support the image option, therefore it will be ignored.

If your system support more than one notifier, you can specify which one you prefer:

Notifier.default_notifier = :notify_send

Alternatively, you can set the default notifier by using the NOTIFIER env var. The following example assumes test_notifier is configured on this Rails project. The env var has precedence of Notifier.default_notifier.

$ NOTIFIER=hud rails test

The available names are terminal_notifier, kdialog, knotify, notify_send, osd_cat, and snarl.

There are several helper methods that you can use in order to retrieve notifiers.

  • Notifier.notifier: return the first supported notifier
  • Notifier.notifiers: return all notifiers
  • Notifier.supported_notifiers: return only supported notifiers
  • Notifier.from_name(name): find notifier by its name
  • Notifier.supported_notifier_from_name(name): find a supported notifier by its name

Creating custom notifiers

To create a new notifier, just create a module on Notifier namespace that implements the following interface:

module Notifier
  module MyCustomNotifier
    def self.supported?
    end

    def self.notify(options)
    end
  end
end

Maintainer

Contributors

https://github.com/fnando/notifier/graphs/contributors

License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

notifier's People

Contributors

djwhitt avatar eriknomitch avatar exviva avatar fnando avatar mattn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

notifier's Issues

uninitialized constant Notifier

After installing notifier (0.1.1) using gem install notifier, I gave it a spin in irb:

~/sandbox/notifier$ irb
>> require 'notifier'
NameError: uninitialized constant Notifier
    from ./notifier.rb:4
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from (irb):2

Conflict with ActionMailer notifier.rb

From what I can tell this directly conflicts with Rails' default method for sending emails: http://api.rubyonrails.org/classes/ActionMailer/Base.html

As long as I have a notifier.rb file in my models folder autotest will not run.

I don't know that there's any way around it, but since I've been having problems with this and haven't found anything similar on google I figured I should make a note of it. It crashes with the following error:

/Users/joeunrue/Rails/myapp/app/models/notifier.rb:1:in `<top (required)>': Notifier is not a class (TypeError)

The error goes away and growl notifications work when I delete my notifier.rb file, which is not something I'm sure I'm willing to do.

Running Tests

Hi,
May I know how to run tests for this gem? The Rakefile points to the test folder but there is no such folder in the repo.
Also, it seems building depends on RSpec >~ 3.0. Also mention that in the gemspec.

PS : I am maintaining the Debian package of this gem.

Growl from the Mac App Store

I've installed Growl from the Mac App Store, and the Growl Notify utility, however, it doesn't look as though notifier can send through notifications to it.

I think it's failing in the supported? method. There doesn't appear to be a GrowlHelper process running for Growl from the Mac App Store, however, there is a process running for /Applications/Growl.app/Contents/MacOS/Growl

The command growlnotify works correctly.

Add "subtitle" support for terminal-notifier

terminal-notifier supports a -subtitle flag which is very helpful and would be great to support.

For other notifiers without a subtitle option, maybe the subtitle could be prepended to the message with a delimiter when subtitle: is passed to Notifier.notify.

What do you think?

Edit: Just FYI I'm using this for notify-push.

Erik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.