-
-
Save no6v/240930 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'ruby-growl' | |
require 'socket' | |
require 'shellwords' | |
require 'cgi' | |
UDPSocket.open do |u| | |
u.bind('localhost', Growl::GROWL_UDP_PORT) | |
loop do | |
packet = u.readpartial(1500) | |
digest = packet.slice!(-16, 16) | |
next if digest != Digest::MD5.digest(packet) | |
version, type, flags, *sizes = packet.unpack(Growl::GNN_FORMAT) | |
next if version != Growl::GROWL_PROTOCOL_VERSION | |
next if type != Growl::GROWL_TYPE_NOTIFICATION | |
data = sizes.pop | |
name, title, desciption, app_name = sizes.map do |size| | |
data.slice!(0, size) | |
end | |
system Shellwords.join(['notify-send', title, CGI.escapeHTML(desciption)]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment