Skip to content

Instantly share code, notes, and snippets.

@jdewind
Created May 28, 2011 12:38
Show Gist options
  • Save jdewind/996835 to your computer and use it in GitHub Desktop.
Save jdewind/996835 to your computer and use it in GitHub Desktop.
require 'real_growl_api'
require 'pp'
module RG
module ClassMethods
attr_accessor :rg_sticky, :rg_priority, :rg_icon
end
module InstanceMethods
def rg(*args)
Kernel.rg_priority ||= 0
Kernel.rg_sticky = true if Kernel.rg_sticky.nil?
icon = Kernel.rg_icon
click = nil
@__growl_app ||= RealGrowl::Application.new("RealGrowl")
if args.last.is_a?(Hash) and (args.last[:icon] or args.last[:click])
icon = args.last[:icon]
click = args.last[:click]
args.pop
end
if RealGrowl.running?
notifications = args.map { |x| x.pretty_inspect }
notifications.each do |x|
@__growl_app.notify(
:title => 'rg',
:description => x,
:priority => Kernel.rg_priority,
:sticky => Kernel.rg_sticky,
:icon => icon
)
end
end
nil
end
end
end
module Kernel
include RG
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment