Monthly Archives: January 2011

Resolving DBus uniqe names

Often you stumble across DBus logs (e.g. originating from bustle or dbus-monitor) which only feature DBus unique names (those :1.xyz numbers) and you can only guess which process it originates from.

Helper script to resolve those addresses to processes (if the system is still running):

#!/bin/bash
 
name=$1
while [ -n "$name" ]
do
    result=`LANG=C dbus-send \
                  --session \
                  --print-reply \
                  --dest=org.freedesktop.DBus \
                  / \
                  org.freedesktop.DBus.GetConnectionUnixProcessID \
                  string:"$name" 2>/dev/null`
    if [ $? -eq 0 ]
    then
        process=`ps ax | grep ^${result##* }`
        echo "$name -> $process"
    fi
    shift; name=$1
done