/usr/share/weechat/python/lnotify.py is in weechat-scripts 20131007-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # Copyright (C) 2010 Kevin Morris <kevr@exdevelopment.net>
# lnotify made to use for libnotify notifications
# This script was adapted from 'notify'
# Hope you guys like it :O
#
# 0.1.2
# added option to display weechat's icon by tomboy64
#
# 0.1.3
# changed the way that icon to WeeChat notification is specified.
# (No absolute path is needed)
# /usr/bin/notify-send isn't needed anymore.
# (pynotify is handling notifications now)
# changed the way that lnotify works. When using gnome 3, every new
# notification was creating a new notification instance. The way that
# it is now, all WeeChat notifications are in a group (that have the
# WeeChat icon and have WeeChat name).
# Got report that it has better look for KDE users too.
import weechat, string, pynotify
weechat.register("lnotify", "kevr", "0.1.3", "GPL3", "lnotify - A libnotify script for weechat", "", "")
# Set up here, go no further!
settings = {
"show_highlight" : "on",
"show_priv_msg" : "on",
"show_icon" : "weechat"
}
# Init everything
if not pynotify.init("WeeChat"):
print "Failed to load lnotify"
for option, default_value in settings.items():
if weechat.config_get_plugin(option) == "":
weechat.config_set_plugin(option, default_value)
# Hook privmsg/hilights
weechat.hook_print("", "irc_privmsg", "", 1, "get_notified", "")
# Functions
def get_notified(data, bufferp, uber_empty, tagsn, isdisplayed,
ishilight, prefix, message):
if (weechat.buffer_get_string(bufferp, "localvar_type") == "private" and
weechat.config_get_plugin('show_priv_msg') == "on"):
buffer = (weechat.buffer_get_string(bufferp, "short_name") or
weechat.buffer_get_string(bufferp, "name"))
if buffer == prefix:
n = pynotify.Notification("WeeChat", "%s said: %s" % (prefix,
message),weechat.config_get_plugin('show_icon'))
if not n.show():
print "Failed to send notification"
elif (ishilight == "1" and
weechat.config_get_plugin('show_highlight') == "on"):
buffer = (weechat.buffer_get_string(bufferp, "short_name") or
weechat.buffer_get_string(bufferp, "name"))
n = pynotify.Notification("WeeChat", "In %s, %s said: %s" % (buffer,
prefix, message),weechat.config_get_plugin('show_icon'))
if not n.show():
print "Failed to send notification"
return weechat.WEECHAT_RC_OK
|