lib/notifier/osd_cat.rb in notifier-0.1.0 vs lib/notifier/osd_cat.rb in notifier-0.1.1
- old
+ new
@@ -1,25 +1,28 @@
module Notifier
module OsdCat
extend self
- FONT = "-bitstream-charter-bold-r-normal--33-240-100-100-p-206-iso8859-1"
- POSITION = "top"
- POSITION_OFFSET = "0"
- ALIGN = "center"
- COLORS = {
- :fail => "orange",
- :success => "green",
- :error => "red"
- }
-
def supported?
RUBY_PLATFORM =~ /(linux|freebsd)/ && `which osd_cat > /dev/null` && $? == 0
end
def notify(options)
- Thread.new do
- `echo #{options[:message].inspect} | osd_cat --font=#{FONT} --shadow=0 --pos=#{POSITION} -o #{POSITION_OFFSET} --delay=4 --outline=4 --align=#{ALIGN} -c #{COLORS[options[:status]]}`
- end
+ color = options.fetch(:color, "white")
+ message = options[:message].inspect.gsub(/!/, "\\!")
+ command = %W[
+ echo #{message} |
+ osd_cat
+ --shadow=0
+ --colour=#{color}
+ --pos=top
+ --offset=10
+ --align=center
+ --font=-adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-*-*
+ --delay=5
+ --outline=4
+ ].join(" ")
+
+ Thread.new { `#{command}` }
end
end
end