Module: Guard::Notifier::NotifySend
- Extended by:
- NotifySend
- Included in:
- NotifySend
- Defined in:
- lib/guard/notifiers/notifysend.rb
Overview
System notifications using notify-send, a binary that ships with the libnotify-bin package on many Debian-based distributions.
Constant Summary
- DEFAULTS =
Default options for the notify-send program
{ :t => 3000 # Default timeout is 3000ms }
- SUPPORTED =
Full list of options supported by notify-send
[:u, :t, :i, :c, :h]
Instance Method Summary (collapse)
-
- (Boolean) available?(silent = false)
Test if the notification program is available.
-
- (Object) notify(type, title, message, image, options = { })
Show a system notification.
Instance Method Details
- (Boolean) available?(silent = false)
Test if the notification program is available.
28 29 30 31 32 33 34 35 |
# File 'lib/guard/notifiers/notifysend.rb', line 28 def available?(silent = false) 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 |
- (Object) notify(type, title, message, image, options = { })
Show a system notification.
47 48 49 50 51 52 53 54 |
# File 'lib/guard/notifiers/notifysend.rb', line 47 def notify(type, title, , image, = { }) command = "notify-send '#{title}' '#{}'" = DEFAULTS.merge().merge({ :i => image }) [:u] ||= notifysend_urgency(type) system(to_command_string(command, SUPPORTED, )) end |