root/lang/ruby/growl/growlclient.rb @ 30649

Revision 577, 1.6 kB (checked in by cho45, 6 years ago)

lang/perl/irssi/scripts/remotegrowl.pl,
lang/ruby/growl,
lang/ruby/growl/Growl.rb,
lang/ruby/growl/growlclient.rb,
lang/ruby/growl/growlserver.rb:

リモートの irssi からローカルの Mac の Growl へ通知するセット

  • Property svn:mime-type set to text/script
  • Property svn:executable set to *
Line 
1#!/usr/bin/ruby
2
3
4require "drb/drb"
5require "optparse"
6
7host, port = 'localhost', '9955'
8title  = message = nil
9icon   = nil
10sticky = false
11type   = 'notice'
12
13app_name, app_icon   = "GrowlRemote", nil
14types, default_types = ["notice"], nil
15 
16
17begin
18        eval(File.read("#{ENV['HOME']}/.growlclient"))
19rescue Errno::ENOENT
20end
21
22
23OptionParser.new do |opts|
24        opts.separator ""
25        opts.separator "Required:"
26        opts.on('-t', '--title TITLE')           {|v| title   = v }
27        opts.on('-m', '--message MESSAGE')       {|v| message = v }
28
29        opts.separator ""
30        opts.separator "Optional:"
31        opts.on('-s', '--sticky')                { sticky = true }
32        opts.on('-i', '--icon FILE (nil)')       {|v| icon = File.read(v) }
33        opts.on('-h', '--host HOST (localhost)') {|v| host = v }
34        opts.on('-p', '--port PORT (9955)')      {|v| port = v }
35       
36        opts.separator ""
37        opts.on('--appname NAME')                     {|v| app_name = v }
38        opts.on('--appicon FILE')                     {|v| app_icon = File.read(v) }
39        opts.on('--type    TYPE')                     {|v| type  = v }
40        opts.on('--types   TYPES', '(comma-deliminated)') {|v| types = v.split(/,/) }
41        opts.on('--dtypes  TYPES', '(comma-deliminated)') {|v| default_types = v.split(/,/) }
42        opts.parse!(ARGV)
43
44        unless title && message
45                puts opts
46                exit
47        end
48
49        unless default_types
50                default_types = types
51        end
52end
53
54begin
55        n = DRbObject.new_with_uri("druby://#{host}:#{port}")
56        s = n.register(app_name, types, default_types, app_icon)
57        if s
58                s.notify(type, title, message, icon, icon, sticky)
59        else
60                n.notify(app_name, title, message, type, icon, sticky)
61        end
62rescue Exception => e
63        if $DEBUG
64                puts e.message
65                puts e.backtrace
66        end
67end
68
Note: See TracBrowser for help on using the browser.