Skip to content

Instantly share code, notes, and snippets.

Created February 19, 2013 15:36
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A minimalistic notify plugin for weechat via libnotify (`notify-send`)
def weechat_init
Weechat.register("notify.rb", "madhatter", "0.1", "GPL3", "Notifications via libnotify", "", "")
Weechat.hook_print("", "", "", 1, "notify_msg", "")
return Weechat::WEECHAT_RC_OK
def notify_msg(data, buffer, date, tags, visible, highlight, nick, message)
# Get the channel's metadata.
data = {}
%w[ away type channel server ].each do |meta|
data[meta.to_sym] = Weechat.buffer_get_string(buffer, "localvar_#{meta}");
data[:away] = !data[:away].empty?
# Remember the own nick name to ignore it in private messages
my_nick = Weechat.info_get('irc_nick', data[:server])
# If it is a highlight, a private message and not myself notify me.
return Weechat::WEECHAT_RC_OK if && data[:type] != 'private' or nick == my_nick
`notify-send -i /usr/share/pixmaps/weechat.xpm "#{nick}" "#{message}"`
return Weechat::WEECHAT_RC_OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment