Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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()
share|improve this answer
    
The main reason I was using upstart was so I can use this in a standard deployment of machines to my dev team. Since there might be a couple of user accounts on a machine I was hoping to avoid per-user configs. If it comes to it it's not impossible however :) –  daubers Dec 16 '11 at 13:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.