← Back to team overview

ubuntu-phone team mailing list archive

Re: dbus cron

 

On 21 November 2015 at 05:36, Wayne Ward <info@xxxxxxxxxxxxxxx> wrote:
> im running a dbus cron to get it to run when screen is closed using this
>
> @hourly export DISPLAY=:0.0 && export
> DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-iuLkZaN3SE &&
> /usr/bin/syncevolution owncloud
>
> which thats what the dbus was iuLkZaN3SE
> after a reboot i run
> echo $DBUS_SESSION_BUS_ADDRESS
> and i get dbus ending in UqWqTUYoyP
>
> is it unique every reboot so will the cron still work using iuLkZaN3SE
> or does it have to change every reboot
> and if so is there a code i can put in that will work every reboot?

The session bus address is picked randomly, yes.  There is code
sourced by your profile so you'll be able to see the session bus when
you run "adb shell" though.  This can be found in the file
/etc/profile.d/dbus-source.sh:  Essentially it sources the file
/run/user/$UID/dbus-session, which declares the environment variable.

So if you created a shell script to run as your cron job, you could
add something like this to it:

    source /run/user/$(id -u)/dbus-session
    export DBUS_SESSION_BUS_ADDRESS

Hope that helps.

James.


References