mcabber + pynotify

Джаббер, аська и прочее

Модератор: /dev/random

Ответить
stfoo
Сообщения: 12

mcabber + pynotify

Сообщение stfoo »

mcabber 0.9.10, python 2.6 Имеется скрипт, который по смыслу обязан рисовать окошко с текстом пришедшего сообщения и воспроизводить при этом некоторый звук. Вот только он этого не делает. Файл с сообщением читается и удаляется, звук проигрывается, а визуальное уведомление не появляется. При всём этом, при запуске скрипта руками (./mcnotify.py MSG IN same@name sometextfile) всё работает.

Код: Выделить всё

#!/usr/bin/python
import sys

CMD_MSG_IN="/usr/bin/aplay /home/foo/.mcabber/notify.wav"
SHORT_NICK=True

if len(sys.argv) == 5:
    event,arg1,arg2,filename = sys.argv[1:5]
else:
    event,arg1,arg2          = sys.argv[1:4]
    filename                 = None

if event == 'MSG' and arg1 == 'IN':
    import pynotify,os,locale
    encoding  = (locale.getdefaultlocale())[1]
    msg = 'sent you a message.'

    if SHORT_NICK and '@' in arg2:
        arg2 = arg2[0:arg2.index('@')]

    if filename is not None:
        f = file(filename)
        msg = f.read()

    pynotify.init('mcnotify')
    msgbox = pynotify.Notification(unicode(arg2, encoding),unicode(msg, encoding))
    msgbox.set_timeout(3000)
    msgbox.set_urgency(pynotify.URGENCY_LOW)
    msgbox.show()
    if (CMD_MSG_IN):
        os.system(CMD_MSG_IN + '> /dev/null 2>&1')

    if filename is not None and os.path.exists(filename):
        os.remove(filename)
        pynotify.uninit()


В mcabberrc:

Код: Выделить всё

set events_command = /home/foo/.mcabber/bin/mcnotify.py
set event_log_files = 1
set event_log_dir = ~/.mcabber/tmp


Куда искать?
Спасибо сказали:
Ответить