Marble/MarbleDBus: Difference between revisions

From KDE TechBase
No edit summary
No edit summary
Line 3: Line 3:
MarbleWidget and MarbleMap provide their full amount of methods as a D-BUS Interface. Therefore you can easily create a shell-script to control Marble using the <b>qdbus</b> command line tool.
MarbleWidget and MarbleMap provide their full amount of methods as a D-BUS Interface. Therefore you can easily create a shell-script to control Marble using the <b>qdbus</b> command line tool.


So assuming that e.g. 25733 would be the PID of the running process you could call
Before you start you need to find out the PID of the Marble process: In your script you can do it like this.


<code>
<code>
qdbus org.kde.marble-25733 /MarbleWidget
marble_pid="$(pidof marble)"
</code>
</code>


to get a list of all the methods that MarbleWidget supports.
Then you can pass this PID to the actual qdbus call
 
<code>
qdbus org.kde.marble-$marble_pid /MarbleWidget
</code>
 
This call returns a list of all the methods that MarbleWidget supports.
From this list you can choose the one that you'd like to call, e.g.
From this list you can choose the one that you'd like to call, e.g.


<code>
<code>
qdbus org.kde.marble-25733 /MarbleWidget org.kde.MarbleWidget.zoomIn
qdbus org.kde.marble-$marble_pid /MarbleWidget org.kde.MarbleWidget.zoomIn
</code>
</code>



Revision as of 15:51, 6 February 2009

Scripting Marble from the shell using D-BUS

MarbleWidget and MarbleMap provide their full amount of methods as a D-BUS Interface. Therefore you can easily create a shell-script to control Marble using the qdbus command line tool.

Before you start you need to find out the PID of the Marble process: In your script you can do it like this.

marble_pid="$(pidof marble)"

Then you can pass this PID to the actual qdbus call

qdbus org.kde.marble-$marble_pid /MarbleWidget

This call returns a list of all the methods that MarbleWidget supports. From this list you can choose the one that you'd like to call, e.g.

qdbus org.kde.marble-$marble_pid /MarbleWidget org.kde.MarbleWidget.zoomIn

to zoom into the map. Note that for function calls you shouldn't pass the brackets "()".

As a convenient tool you can use qdbusviewer to get a graphical list of the interfaces and methods that get provided through D-BUS.


This article is a stub, please extend it.