commandline tool to trigger actions on dbus-signal

Mikkel Kamstrup Erlandsen mikkel.kamstrup at canonical.com
Tue Feb 22 00:24:02 PST 2011


On Mon, 2011-02-21 at 22:27 +0100, Robin Gareus wrote:
> Hi *,
> 
> I'm searching a simple commandline-tool (akin to dbus-monitor,
> dbus-send) that invokes a shell-command upon receiving a given dbus signal.
> 
> I'm new around here. If there's a better place to get answers to this
> question, please advice.
> 
> I'm wondering if it's worth to pursue
>  git://rg42.org/dbustriggerd
> 
> I'm interested in alternatives: What do you do to trigger shell-commands
> via dbus messages? Can it be done [easily] without resorting to
> dbus-python or other binding languages?

dbus-monitor can do this for you already. You can give dbus-monitor an
arbitrary match rule string[1], so an example match on a signal:

  dbus-monitor
"type='signal',interface='com.example.SuperService',member='DuperSignal'"

Then pipe that into some process that reads from stdin, does something,
and then exits once it reads anything off stdin.

I've never actually tried this, but I'm pretty sure it should work. The
crucial point is whether dbus-monitor exits if stdout is closed. And it
does - I just checked dbus-monitor | head -1 :-)

Cheers,
Mikkel

http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing



More information about the dbus mailing list