class NotifySend

Constants

DEFAULTS

Public Class Methods

send(first, *others) click to toggle source
# File lib/notify-send.rb, line 17
def self.send(first, *others)
        if first.is_a?(Hash) and others.length == 0
                _send first
        elsif first.respond_to?(:to_s) and others.length < 4
                _send [:body, :icon, :timeout].zip(others).each_with_object({summary: first}) { |(k, v), obj| obj[k] = v unless v.nil? }
        else
                raise ArgumentError.new("Invalid arguments")
        end
        # _send DEFAULTS.merge(first.is_a?(Hash) ? first : {summary: first, body: others[0]})
end

Private Class Methods

_send(params) click to toggle source
# File lib/notify-send.rb, line 41
def self._send(params)
        interface.Notify *DEFAULTS.merge(params).values
end
get_interface() click to toggle source
# File lib/notify-send.rb, line 34
def self.get_interface
        bus = DBus::SessionBus.instance
        obj = bus.service("org.freedesktop.Notifications").object "/org/freedesktop/Notifications"
        obj.introspect
        obj["org.freedesktop.Notifications"]
end
interface() click to toggle source
# File lib/notify-send.rb, line 30
def self.interface
        @@interface ||= get_interface
end