[Galago-devel] Re: Passing a notification from root to user with notification-daemon

Marco marcodefreitas at gmail.com
Wed Apr 4 07:03:30 EEST 2007


Brian Sutherland <jinty <at> web.de> writes:

> 
> On Sun, Mar 12, 2006 at 11:29:46PM -0800, Christian Hammond wrote:
> > On Fri, Mar 10, 2006 at 06:46:14PM +0100, Brian Sutherland wrote:
> > > Hi,
> > > 
> > > This may not be the right place for this, but here goes:
> > > 
> > > I am developing an excruciatingly small program that passes
> > > notifications of possible hard disk issues from smartd to the
> > > user. It looks like the notification-daemon might be the right thing to
> > > use.
> > > 
> > > But I fail to find in the documentation how to pass a notification from
> > > the root to the user context? Is there a "Right Way"? Could someone
> > > point me in the right direction? 
> > 
> > Unfortunately, there is no "right way." You would have to talk to the
> > user's session bus (or all users' session busses). That's more of a
> > general D-BUS issue rather than a notification issue. Now, we could
> > extend the notification framework to also listen on the system bus,
> > but that's tricky and requires a lot more thought.
> 
> That's kind of what I have right now, I run a per-user-session-daemon
> that listens to the system bus. But I agree it is tricky and would love
> to move to a solution where the trickiness is handled for me.
> 
> > For the time-being,
> > I don't have a good answer for you, except find a way to listen to the
> > notifications (per-user) and then emit a notification. So, a proxy of
> > sorts for this specific case.
> 
> This sets off my in-built complexity meter;)
> 
> Thanks for the reply, even a negative result is useful sometimes...
> 
I have the same problem.
I'm coding a shell script to notify me when ppp0 is up but it don't work if root:
# /etc/ppp/ip-up.d/90ppp-connect
libnotify-Message: Unable to get session bus: Did not receive a reply. Possible
causes include: the remote application did not send a reply, the message bus
security policy blocked the reply, the reply timeout expired, or the network
connection was broken.
unix:abstract=/tmp/dbus-MTlwZSeoD5,guid=f404e303bbfed9dea1500c0046128b75

(it works as expected)

file: /etc/ppp/ip-up.d/90ppp-connect:

#!/bin/bash
title="Conectado"
text="$(tail -1 /var/log/ppp-connect-errors)"
pids=`pgrep gnome-session`
for pid in $pids; do
        # find DBUS session bus for this session
        DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS \
                /proc/$pid/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//'`
        # use it
        DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
        notify-send -u low "$title" "$text"
        echo $DBUS_SESSION_BUS_ADDRESS
done







More information about the galago-devel mailing list