Last Updated: February 25, 2016
·
1.05K
· hoffoo

Dbus for a better world

Dbus is a daemon on linux systems that allows applications to talk to one another via external methods. The internals can be pretty detailed,but it is quite easy to learn it well enough to talk to applications via simple scripts.

Pretty much every language has a mature, well maintained library to do this, including C, Java, Go and Python.

A lot of times I just want to call a method in another application. This is very easy just from a shell script, here is an example:
https://github.com/hoffoo/gmusicbrowser-ctrl/blob/master/gmb-ctrl.sh

This is a library that I have used for java:
http://dbus.freedesktop.org/doc/dbus-java/dbus-java/

In Go a well featured library is here:
https://github.com/godbus/dbus

Below is an example in go of how to use this library to talk to Spotify, call methods, and get information about the current song:

https://github.com/hoffoo/go-spotify/blob/master/spotify.go