2

I have a python script that gets messages from an MQTT server and parses them to display using libnotify. This works fine when I run it from a terminal, but when I run it using upstart I get no notification bubbles. I assume because it doesn't understand which X display and Xauthority file to use.

When I did something similar with cron I had to set it up as */10 * * * * DISPLAY=:0.0 XAUTHORITY=~/.Xauthority notify-send "Don't forget" "you're awesome" I assume I need to do something similar with upstart to make this work? Or is there a way to get libnotify to broadcast to all xscreens or somesuch?

Thanks for any advice or pointers

daubers
  • 103

1 Answers1

1

Would you be better off approaching this problem from a different angle?

I'd try run your script on login by putting a .desktop file in ~/.config/autostart and ensure that the script restarts itself if there's a network problem (I assume that's why you're using upstart).

Something like this perhaps:

while 1:
    rc = 0
    while rc == 0:
        rc = client.loop()
    # Check error code, possibly pause for a while
    client.reconnect()
Roger Light
  • 1,384