Python: pynotify network problem

662 Views Asked by At

I am using 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?

3

There are 3 best solutions below

1
On BEST ANSWER

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).

1
On

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.

0
On

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

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