Module: Notifier::OsdCat

Extended by:
OsdCat
Included in:
OsdCat
Defined in:
lib/notifier/osd_cat.rb

Instance Method Summary collapse

Instance Method Details

#notify(options) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/notifier/osd_cat.rb', line 9

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

#supported?Boolean

Returns:

  • (Boolean)

5
6
7
# File 'lib/notifier/osd_cat.rb', line 5

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