class Notiffany::Notifier::NotifySend


notification :notifysend
@example Add the ‘:notifysend` notifier to your `Guardfile`
the libnotify-bin package on many Debian-based distributions.
System notifications using notify-send, a binary that ships with

def _check_available(_opts = {})

def _check_available(_opts = {})
  which = Shellany::Sheller.stdout("which notify-send")
  return true unless which.nil? || which.empty?
  fail UnavailableError, "libnotify-bin package is not installed"
end

def _gem_name

notify-send has no gem, just a binary to shell out
def _gem_name
  nil
end

def _notifysend_urgency(type)

Returns:
  • (String) - the notify-send urgency

Parameters:
  • type (String) -- the Guard notification type
def _notifysend_urgency(type)
  { failed: "normal", pending: "low" }.fetch(type, "low")
end

def _perform_notify(message, opts = {})

Options Hash: (**opts)
  • t (Number) -- the number of milliseconds to display (1000,
  • c (String) -- the notification category
  • image (String) -- the path to the notification image
  • title (String) -- the notification title
  • type (String) -- the notification type. Either 'success',

Parameters:
  • opts (Hash) -- additional notification library options
  • message (String) -- the notification message body
def _perform_notify(message, opts = {})
  command = [opts[:title], message]
  opts = opts.merge(
    i: opts[:i] || opts[:image],
    u: opts[:u] || _notifysend_urgency(opts[:type])
  )
  Shellany::Sheller.
    run("notify-send", *_to_arguments(command, SUPPORTED, opts))
end

def _supported_hosts

def _supported_hosts
  %w(linux linux-gnu freebsd openbsd sunos solaris)
end

def _to_arguments(command, supported, opts = {})

Returns:
  • (Array) - the command and its options converted to a

Parameters:
  • opts (Hash) -- additional command options
  • supported (Array) -- list of supported option flags
  • command (String) -- the command execute
def _to_arguments(command, supported, opts = {})
  opts.inject(command) do |cmd, (flag, value)|
    supported.include?(flag) ? (cmd << "-#{flag}" << value.to_s) : cmd
  end
end