Class: RiotNotifier::Libnotify

Inherits:
Base
  • Object
show all
Defined in:
lib/riot_notifier/libnotify.rb

Constant Summary collapse

OPTIONS =
{
  :green => {
    :icon_path => "/usr/share/icons/gnome/scalable/emblems/emblem-default.svg",
    :timeout => 2.5,
    :urgency => :normal,
    :summary => ":-)"
  },
  :red => {
    :icon_path => "/usr/share/icons/gnome/scalable/emotes/face-angry.svg",
    :timeout => 2.5,
    :urgency => :critical,
    :summary => ":-("
  }
}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#error, #fail, inherited, #initialize, #results

Constructor Details

This class inherits a constructor from RiotNotifier::Base

Class Method Details

.usable?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
# File 'lib/riot_notifier/libnotify.rb', line 26

def self.usable?
  require 'libnotify'
  true
rescue LoadError
  false
end

Instance Method Details

#notify(color, msg) ⇒ Object



20
21
22
23
24
# File 'lib/riot_notifier/libnotify.rb', line 20

def notify(color, msg)
  options = OPTIONS[color] or raise "unknown color #{color}"

  ::Libnotify.show(options.merge(:body => msg))
end