Sha256: 1428246312d9ced008847188a00f8b6a808e496628751c621594d2aadd9d05dd

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

# Notifies via libnotify.
module RiotNotifier

  class Libnotify < Base
    ICON = {
      :green  =>  "emblem-default.png",
      :red    =>  "false-angry.png"
    }

    OPTIONS = {
      :green => {
        :icon_path => ICON[:green],
        :timeout => 2.5,
        :urgency => :normal,
        :summary => ":-)"
      },
      :red => {
        :icon_path => ICON[:red],
        :timeout => 2.5,
        :urgency => :critical,
        :summary => ":-("
      }
    }

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

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

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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riot_notifier-0.5.0 lib/riot_notifier/libnotify.rb