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
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
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 = [title, message] options = DEFAULTS.merge(options).merge({ :i => image }) options[:u] ||= notifysend_urgency(type) system('notify-send', *to_arguments(command, SUPPORTED, options)) end
Generated with the Darkfish Rdoc Generator 2.