Sha256: 70320fa5bc3c02bbb630f6d461f88302144f9dc950645237cc7487538496ec51

Contents?: true

Size: 1021 Bytes

Versions: 2

Compression:

Stored size: 1021 Bytes

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

2 entries across 2 versions & 1 rubygems

Version Path
fgrehm-autotestforphp-0.0.1 lib/autotestforphp/notification/linux.rb
fgrehm-autotestforphp-0.0.2 lib/autotestforphp/notification/linux.rb