LINUX.ORG.RU

Я просто выставляю urgent. Вот немножко перепиленный плагин:

import weechat
from subprocess import Popen

# Set up here, go no further!
settings = {
    "show_highlight"     : "on",
    "show_priv_msg"      : "on",
}

def notify():
    out = open('/dev/null', 'w')
    p = Popen('( xprop -id `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d " " -f 5`'
        ' | egrep -q "WM_NAME.*weechat" ) || wmctrl -xr "weechat" -b add,demands_attention',
        shell=True, stderr=out, stdout=out)
    p.wait()

# 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:
            notify()

    elif (ishilight == "1" and weechat.config_get_plugin('show_highlight') == "on"):
        notify()

    return weechat.WEECHAT_RC_OK

def main():
    weechat.register("unotify", "bobrov", "0.1", "GPL3",
        "unotify - A n urgent notify script for weechat", "", "")

    # Init everything
    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", "")

main()

Из зависимостей нужен wmctrl и xprop. И запуск терминала с "-name weechat".

baverman ★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.