Please note: This is not the similar-sounding FAQ that involves a multi-headed display. This question is about two different computers.
If I log onto the console of two different computers, sitting-at.example.com and sshed-into.example.com, and then sitting in front of sitting-at.example.com I ssh (with X11 tunneling) into sshed-into.example.com...
If I do that and then run a little Python script that uses libnotify, the notification pops up on the console of sshed-into.example.com, not sitting-at.example.com. But I need the notification on sitting-at.example.com. It seems to me that would make more sense.
The result is I do not see the notification until I drive to the other location and log back into the console of sshed-into.example.com.
My code has a fallback to use a little GTK popup if libnotify raises an exception, but it doesn't kick in because as far as libnotify is concerned, things are working fine.
I could use the GTK popup all the time, like I used to, but I kinda like libnotify where feasible. For one thing, libnotify doesn't get lost if I click to a different virtual desktop or raise a window at an inopportune moment. The GTK popup does.
Is there a way of getting either a remote notification using libnotify, xor of getting an exception?
I've considered parsing $DISPLAY to see if it "looks local", but it seems like there should be a better way.
Thanks in advance!
PS: The code for the little script is opensource and can be found at http://stromberg.dnsalias.org/~strombrg/notify-when-up2.html
I wound up checking $DISPLAY, since the responses here weren't flowing thick and fast.
The function I used:
def is_local_display(regex=re.compile(r'^:0(\.[0-9]+)?$')):
"""Return True iff $DISPLAY points at a local display."""
if 'DISPLAY' not in os.environ:
return False
match = regex.match(os.environ['DISPLAY'])
return bool(match)