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
@private
@return [Boolean] whether or not the notify-send binary is available
# File lib/guard/notifiers/notifysend.rb, line 35 def self._notifysend_binary_available? !`which notify-send`.empty? end
@private
Detects if the notify-send binary is available and if not, displays an error message unless `opts` is true.
@return [Boolean] whether or not the notify-send binary is available
# File lib/guard/notifiers/notifysend.rb, line 46 def self._register!(opts) if _notifysend_binary_available? true else unless opts[:silent] ::Guard::UI.error 'The :notifysend notifier runs only on Linux, FreeBSD, OpenBSD and Solaris with the libnotify-bin package installed.' end false end end
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 [String] c the notification category @option opts [Number] t the number of milliseconds to display (1000,
3000)
# File lib/guard/notifiers/notifysend.rb, line 69 def notify(message, opts = {}) super command = [opts[:title], message] opts = DEFAULTS.merge( i: opts.delete(:image), u: _notifysend_urgency(opts.delete(:type)) ).merge(opts) system('notify-send', *_to_arguments(command, SUPPORTED, opts)) end
Generated with the Darkfish Rdoc Generator 2.