I am trying to write a bash script which will launch a program (konsole) and send dbus messages to it. Here is my experiment
konsole &
echo pid is $!
ps aux | grep konsole
qdbus | grep konsole
This outputs
pid is 2726
me 2726 0.0 0.4 45404 9952 pts/0 S+ 14:59 0:00 konsole
org.kde.konsole-2729
The qdbus service name is always org.kde.konsole-{pid+epsilon}
but the epsilon part is unpredictable.
In my bash script, how do I get the exact qdbus service name for the particular konsole instance I just spawned?
Here's a nasty, hacky solution
qdbus | grep konsole | sed 's/[^0-9]//g' > /tmp/before
konsole &
sleep 1
qdbus | grep konsole | sed 's/[^0-9]//g' > /tmp/after
N=`sort /tmp/before /tmp/after | uniq -u`
but surely there's a better way!