Files

Guard::Notifier::Libnotify

System notifications using the [libnotify](github.com/splattael/libnotify) gem.

This gem is available for Linux, FreeBSD, OpenBSD and Solaris and sends system notifications to Gnome [libnotify](developer.gnome.org/libnotify):

@example Add the `libnotify` gem to your `Gemfile`

group :development
  gem 'libnotify'
end

@example Add the `:libnotify` notifier to your `Guardfile`

notification :libnotify

@example Add the `:libnotify` notifier with configuration options to your `Guardfile`

notification :libnotify, timeout: 5, transient: true, append: false, urgency: :critical

Constants

DEFAULTS

Default options for the libnotify notifications.

Public Class Methods

available?(opts = {}) click to toggle source
# File lib/guard/notifiers/libnotify.rb, line 37
def self.available?(opts = {})
  super and require_gem_safely(opts)
end
supported_hosts() click to toggle source
# File lib/guard/notifiers/libnotify.rb, line 33
def self.supported_hosts
  ]linux freebsd openbsd sunos solaris]
end

Public Instance Methods

notify(message, opts = {}) click to toggle source

Shows a system notification.

@param [String] message the notification message body @param [Hash] opts additional notification library options @option opts [String] type the notification type. Either ‘success’,

'pending', 'failed' or 'notify'

@option opts [String] title the notification title @option opts [String] image the path to the notification image @option opts [Boolean] transient keep the notifications around after

display

@option opts [Boolean] append append onto existing notification @option opts [Number, Boolean] timeout the number of seconds to display

(1.5 (s), 1000 (ms), false)
# File lib/guard/notifiers/libnotify.rb, line 55
def notify(message, opts = {})
  super
  self.class.require_gem_safely

  opts = DEFAULTS.merge(
    summary:   opts.delete(:title),
    icon_path: opts.delete(:image),
    body:      message,
    urgency:   _libnotify_urgency(opts.delete(:type))
  ).merge(opts)

  ::Libnotify.show(opts)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.