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 was wandering if it is possible to access the DBUS session bus from within an upstart script.

The background is this:
I am running an upstart task in user mode and replaced the Upstart.conf dbus configuration file with the one from the upstart bzr repository.

Now it would like to access the gnome keyring within that tasks script using gkeyring, which needs to access the users upstart session bus. By default, I just get the Gnome keyring not available.

When I try to export DBUS_SESSION_BUS_ADDRESS=... within the upstart script, the script/initctl command just hangs, no output anywhere.

This leads me to believe that since upstart uses DBUS as well, using the session bus is problematic. Does someone have an idea to resolve this?

share|improve this question
    
There could be multiple session buses for a user, so this isn't an easy one to answer. Have you considered launching your app as part of the user session instead? –  James Henstridge Sep 15 '12 at 0:12
    
problem with that approach, is lack of robustness on failure, upstart restarts/logs as such. –  kevinf Sep 19 at 4:35

1 Answer 1

this might work for you ?...

script
    export HOME="/home/puma"
    chdir /home/puma/apps/whatever/bin
    dbus_file=$(ls $HOME/.dbus/session-bus/ -t1 | head -1)
    . "$HOME/.dbus/session-bus/$dbus_file"
    export DBUS_SESSION_BUS_ADDRESS
    exec su -s /bin/sh -c 'export DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS;exec /home/puma/apps/whatever/bin/appname' puma 
end script

hope it helps ?

share|improve this answer
    
This worked PERFECTLY! Thank you very much, i tried all the methods superuser.com/questions/213416/… and this is what worked... bluez-mpris-player aka mpris-proxy requires access to the session bus that your mpris2 player (Audacious) is running on. Now I have working AVRCP 1.3 (track changed metadata) with Bluez 4.101 (org.bluez.MediaPlayer) on Precise 12.04.5 with my carputer, paired to A2DP Bluetooth in Toyota Corolla I hope those with google foo can find this! –  kevinf Sep 19 at 4:34

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.