Sha256: eaa942b7635c9da8d882cf97299bed24c63f9e0ce40913c637108a18847e157a

Contents?: true

Size: 781 Bytes

Versions: 4

Compression:

Stored size: 781 Bytes

Contents

# frozen_string_literal: true

module Notifier
  module OsdCat
    extend self

    def supported?
      Notifier.os?(/(linux|freebsd)/) &&
        `which osd_cat > /dev/null` &&
        $CHILD_STATUS == 0
    end

    def notify(options)
      color = options.fetch(:color, "white").to_s

      command = [
        "osd_cat",
        "--shadow", "0",
        "--colour", color,
        "--pos", "top",
        "--offset", "10",
        "--align", "center",
        "--font", "-bitstream-bitstream charter-bold-r-*-*-*-350-*-*-*-*-*-*",
        "--delay", "5",
        "--outline", "4"
      ]

      Thread.new do
        Open3.popen3(*command) do |stdin, _stdout, _stderr|
          stdin.puts options[:message]
          stdin.close
        end
      end.join
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
notifier-1.2.2 lib/notifier/osd_cat.rb
notifier-1.2.1 lib/notifier/osd_cat.rb
notifier-1.1.0 lib/notifier/osd_cat.rb
notifier-1.0.0 lib/notifier/osd_cat.rb