[Dextrose] Send Notification at sugar start up

Aleksey Lim alsroot at activitycentral.org
Fri Mar 4 06:09:14 EST 2011


On Fri, Mar 04, 2011 at 08:23:58AM -0200, Esteban Bordon wrote:
> I run the script using olpc user
> 
> su -c "export DISPLAY=:0.0; /usr/bin/python my_script.py" olpc
> 
> This call works well but it's ignored at sugar start.

btw if you run your script just before lauching sugar, it is not being
ignored, sugar just never get it.

> A possible workaround can be put this line into cron.daily and configure it
> to run few minutes after start. I tested it and works but I don't know if
> it's the best way to do.

No idea how you managed to make it run. the cron process shouldn't know
dbus session ($DBUS_SESSION_BUS_ADDRESS) and sugar never get the signal
sent from cron process.

If you just, for some reason, need to send dbus signal to sugar on its
startup, use dbus-send command, eg, from .xsession file:

    send() {
        # wait for sugar start
        sleep 3
        dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.Notify string:"app" uint32:0 string:"icon" string:"summary" string:"body" array:string: dict:string:string: int32:0
    }

    send &

    exec sugar....

> 
> Regards,
> Esteban.
> 
> 
> 
> 2011/3/4 Aleksey Lim <alsroot at activitycentral.org>
> 
> > On Thu, Mar 03, 2011 at 11:24:44AM -0200, Esteban Bordon wrote:
> > > Hi all,
> > >
> > > I want to show a simple notification when sugar starts up.
> > >
> > > I have a python script like this:
> > >
> > > import dbus
> > > BUS_NAME = 'org.freedesktop.Notifications'
> > > OBJ_PATH = '/org/freedesktop/Notifications'
> > >
> > > IFACE_NAME = 'org.freedesktop.Notifications'
> > > bus = dbus.SessionBus()
> > > notify_obj = bus.get_object(BUS_NAME,OBJ_PATH)
> > > notifications = dbus.Interface(notify_obj,IFACE_NAME)
> > > notifications.Notify("HelloWorld",0,'',"Summary","Body",[],{},-1)
> > >
> > > The script works fine, but I couldn't run it at sugar start up. I
> > > tried to call the script in .xsession and sugar-session but didn't
> > > work.
> > >
> > > Any idea?
> >
> > The problem might occur due to different dbus sessions,
> > make sure that sugar and the session you send dbus messages from are
> > using the same dbus session.
> >
> >
> > >
> > >
> > > Thanks,
> > > Esteban.
> >
> > > _______________________________________________
> > > Dextrose mailing list
> > > Dextrose at lists.sugarlabs.org
> > > http://lists.sugarlabs.org/listinfo/dextrose
> >
> >
> > --
> > Aleksey
> >

-- 
Aleksey


More information about the Dextrose mailing list