开发者

Python: pynotify network problem

开发者 https://www.devze.com 2022-12-11 20:04 出处:网络
I am u开发者_如何学运维sing pynotify and this is the code I am trying to get to work: #! /usr/bin/python

I am u开发者_如何学运维sing pynotify and this is the code I am trying to get to work:

#! /usr/bin/python
try:
    import pynotify
    if pynotify.init("Telebrama Alert"):
        n = pynotify.Notification('Message','This is test message')
        n.set_urgency(pynotify.URGENCY_CRITICAL)
        n.show()
    else:
        print 'There was a problem in initializing the pynotify module'
except:
    print "you don't seem to installed pynotify\n"

It is working fine on my computer. But I want to send some notification to another network. How can I make it work?


pynotify is just an X client. To connect non-local X server you have to set DISPLAY environment variable. Note, that X server you are going to connect to should be configured to accept remote connections (see man pages for xhost and xauth).


Well you should understand pynotify is not about network.

pynotify is the Python binding for libnotify. libnotify is about desktop (local) notification. It uses the local D-Bus message bus. No network. So if you want to send a notification to another desktop you will have to use some other tool.


Depending on your DISPLAY variable, you can get this to work by:

import os os.environ['DISPLAY'] = ':0.0'

0

精彩评论

暂无评论...
验证码 换一张
取 消