Astro-scripting using KStars' D-Bus interface

I was telling Henry about
an interesting use case of KStars a few days ago, and he
suggested that I blog about it.

I encountered this problem while preparing for a Practical Amateur Astronomy workshop that we were organizing. We had made lists of
various celestial objects for people to observe, along with some
hand-written descriptions. We edited the lists collaboratively on
Google Spreadsheets, and at some point I declared the lists final and
made a CSV export. I wanted the lists to be organized by constellation
and also have some more vital information about the objects filled in.

Enter KStars and D-Bus. KStars has D-Bus interface functions that let
you access many of its features. I use qdbus to access
them over the shell. (Note that the following is known to work on
GNU/Linux. I am entirely unsure about Windows and Mac
platforms). Here’s a brief example of making KStars point towards M

qdbus org.kde.kstars /KStars org.kde.kstars.lookTowards "M 33"

(Note: Due to some bug in KStars at the moment, you need to invoke the
above multiple times to get the object in the center)

Then, let’s say we want to query information on NGC 2903. We can do so
by using:

$ qdbus org.kde.kstars /KStars org.kde.kstars.getObjectDataXML "NGC 2903"

and KStars outputs an XML blurb describing the object.

One can now use tools like xmlstarlet to work with the
XML on the command line.

There. That has all the information I need to complete the
checklists. So I went ahead and wrote a small shell script to order
the objects by constellation and typeset a table using LaTeX. The
results look like this:


Many more wonderful things are possible because of the D-Bus
interface. In fact, my Logbook project
relies heavily on KStars’ D-Bus interface. The Logbook project uses
KStars to produce amateur astronomers’ logbooks complete with fine and
coarse finder charts, relevant data and DSS imagery.

One can use qdbusviewer and qdbus to further
explore the available D-Bus methods in KStars and profit from
scripting using KStars.