Sha256: 15397b2593b6d0854882ccebf230be41034148e5350cb4b56a185fcdca66ac2f

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

class Autotestforphp
  module Notification
    module Linux
      class << self

        def notify(title, msg, img)
          if has_notify?
            notify_send(title, msg, img)
          elsif has_zenity?
            zenity(title, msg, img)
          elsif has_kdialog?
            kdialog(title, msg, img)
          end
        end

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

        def has_kdialog?
          system "which kdialog > /dev/null 2>&1"
        end

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

        def notify_send(title, msg, img)
          system "notify-send -i #{img} '#{title}' '#{msg}'"
        end

        def kdialog(title, msg, img)
          system "kdialog --title '#{title}' --passivepopup '<img src=\"#{img}\" align=\"middle\"> #{msg}'"
        end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
autotestforphp-0.0.3 lib/autotestforphp/notification/linux.rb