Sha256: b877890d580387e61249769939e56554c25306dd92ea56ed7f9ddbe8a7932ba3

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

module AutotestNotification
  class Linux
    class << self
      def notify(title, msg, img)
        if has_notify?
          notify_send(title, msg, img)
	      elsif has_zenity?
	        zenity(title, msg, img)
        else
          kdialog(title, msg, img)
        end
      end

      protected
        def notify_send(title, msg, img)
          system "notify-send -t #{EXPIRATION_IN_SECONDS * 1000} -i #{img} '#{title}' '#{msg}'"
        end

        def kdialog(title, msg, img)
          system "kdialog --title '#{title}' --passivepopup '#{msg}' #{EXPIRATION_IN_SECONDS}"
        end

	      def zenity(title, msg, img)
	        system "zenity --info --text='#{msg}' --title='#{title}'"
	      end

        def has_zenity?
          system "which zenity 2> /dev/null"
        end

        def has_notify?
          system "which notify-send 2> /dev/null"
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
carlosbrando-autotest-notification-0.2.0 lib/autotest_notification/linux.rb
carlosbrando-autotest-notification-0.2.1 lib/autotest_notification/linux.rb
urubatan-autotest-notification-0.2.0 lib/autotest_notification/linux.rb