Files

Guard::Notifier::NotifySend

System notifications using notify-send, a binary that ships with the libnotify-bin package on many Debian-based distributions.

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

notification :notifysend

Constants

DEFAULTS

Default options for the notify-send program

SUPPORTED

Full list of options supported by notify-send

Public Instance Methods

available?(silent = false, options = {}) click to toggle source

Test if the notification program is available.

@param [Boolean] silent true if no error messages should be shown @param [Hash] options notifier options @return [Boolean] the availability status

# File lib/guard/notifiers/notifysend.rb, line 31
def available?(silent = false, options = {})
  if (RbConfig::CONFIG['host_os'] =~ /linux|freebsd|openbsd|sunos|solaris/) and (not `which notify-send`.empty?)
    true
  else
    ::Guard::UI.error 'The :notifysend notifier runs only on Linux, FreeBSD, OpenBSD and Solaris with the libnotify-bin package installed.' unless silent
    false
  end
end
notify(type, title, message, image, options = { }) click to toggle source

Show a system notification.

@param [String] type the notification type. Either 'success', 'pending', 'failed' or 'notify' @param [String] title the notification title @param [String] message the notification message body @param [String] image the path to the notification image @param [Hash] options additional notification library options @option options [String] c the notification category @option options [Number] t the number of milliseconds to display (1000, 3000)

# File lib/guard/notifiers/notifysend.rb, line 50
def notify(type, title, message, image, options = { })
  command = "notify-send '#{title}' '#{message}'"
  options = DEFAULTS.merge(options).merge({
    :i => image
  })
  options[:u] ||= notifysend_urgency(type)
  system(to_command_string(command, SUPPORTED, options))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.