-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnotification_center.rb
45 lines (37 loc) · 1.21 KB
/
notification_center.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# See installation instructions at
# https://github.com/wallace/weechat-notification-center-rb
# Derived from https://github.com/tinifni/gntp-notify
require 'rubygems'
require 'weechat'
require 'terminal-notifier'
include Weechat
def weechat_init
Weechat.register("notification_center_rb",
"Jonathan Wallace",
"0.0.1",
"GPL3",
"Ruby Notification Center",
"0.0.5",
"Pass highlights and private messages to the OS X 10.8+ Notification Center")
hook_notifications
return Weechat::WEECHAT_RC_OK
end
def hook_notifications
Weechat.hook_signal("weechat_pv", "show_private", "")
Weechat.hook_signal("weechat_highlight", "show_highlight", "")
end
def unhook_notifications(data, signal, message)
Weechat.unhook(show_private)
Weechat.unhook(show_highlight)
end
def show_private(data, signal, message)
show_notification("Weechat Private Message", message)
return Weechat::WEECHAT_RC_OK
end
def show_highlight(data, signal, message)
show_notification("Weechat", message)
return Weechat::WEECHAT_RC_OK
end
def show_notification(title, message)
TerminalNotifier.notify(message, { :title => title })
end