Skip to content

Instantly share code, notes, and snippets.

@ohac
Created November 22, 2009 04:43
Show Gist options
  • Save ohac/240427 to your computer and use it in GitHub Desktop.
Save ohac/240427 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'ruby-growl'
require 'socket'
u = UDPSocket.new
u.bind('localhost', 9887)
loop do
msg, inetaddr = u.recvfrom(1500)
gnn = msg.unpack(Growl::GNN_FORMAT)
next if gnn.shift != 1 # version
next if gnn.shift != 1 # type
flags = gnn.shift # 0x000e -> priority, 0x0001 -> stiky
str = gnn.pop
pt = 0
ls = (gnn + [ 16 ]).map{|l| str[pt, l].tap{pt += l}}
name, title, desc, app, md5 = ls
`notify-send '#{title}' '#{desc}'` # TODO not secure
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment