Jajuk Advanced Jukebox

Follow us on GitHub

Go back to the TOC

D-bus

How to get D-Bus working

D-Bus for Jajuk is provided by the open source library for D-Bus binding for Java and a few additional .jar files that are used by this library. Most of the setup is done “behind the scenes”, if you are using a Unix-like operating system that uses a X-Window Manager with support for D-Bus, it should work out of the box. During startup, Jajuk tries to establish a connection to the D-Bus session daemon to provide it’s interfaces to all applications running in the same session.

Remote control

The following applications allow to test controlling Jajuk remotely, “dbus-send” and “qdbus” can also be used to create scripts that control Jajuk, i.e. integration in LIRC or other systems:

 
dbus-send --session --print-reply --dest=org.jajuk.dbus.DBusSupport  /JajukDBus org.jajuk.services.dbus.DBusSupport.next

KDE has also support for linking dbus-actions to keyboard shortcuts in the system settings dialogs for keyboard shortcuts, see bellow for details.

Native library

$JAVA_BIN $JAVA_OPTIONS -Djava.library.path=$JAJUK_HOME/../lib -jar jajuk.jar $JAJUK_OPTIONS

Troubleshooting

Cannot Resolve Session Bus Address

During startup the Error “Cannot Resolve Session Bus Address” is reported and DBus-support does not work. The logfile will show the following:

2009/05/22 08:58:41 [INFO] Trying to start support for D-Bus on Linux with Bus:   
[Startup Async After Collection Load Thread] (Log.java:148) 
2009/05/22 08:58:41 [ERROR] Cannot Resolve Session Bus Address / null 
[Startup Async After Collection Load Thread] (Log.java:276) 
org.freedesktop.dbus.exceptions.DBusException: Cannot Resolve Session Bus Address
	at org.freedesktop.dbus.DBusConnection.getConnection(Unknown Source)
	at org.jajuk.services.dbus.DBusSupportImpl.connect(DBusSupportImpl.java:75)
	at org.jajuk.services.dbus.DBusManager.<init>(DBusManager.java:48)
	at org.jajuk.services.dbus.DBusManager.getInstance(DBusManager.java:38)
	at org.jajuk.services.core.StartupService$2.run(StartupService.java:258)

Solution

In order to access the D-Bus session-wide bus, the D-Bus libraries use an environment variable DBUS_SESSION_BUS_ADDRESS which is set by the dbus-startup scripts. Ensure that this environment variable is available. E.g. check the output of the following command:

set | grep DBUS

It should print out something like:

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-nFsYERQLN6,guid=42fbbb828bf5a6bc6adcf2514a028b67

If this environment variable is not set, ensure that the d-bus support is started correctly in your operating system configuration/installation.

Appendix: Using xbindkeys to enable multimedia keys to control Jajuk
"amixer -q set PCM 5%+ unmute"
  XF86AudioRaiseVolume

"amixer -q set PCM 5%- unmute"
  XF86AudioLowerVolume

"amixer -q set Master toggle"
  XF86AudioMute

"dbus-send --session --print-reply --dest=org.jajuk.dbus.DBusSupport /JajukDBus org.jajuk.services.dbus.DBusSupport.next"
  XF86AudioNext

"dbus-send --session --print-reply --dest=org.jajuk.dbus.DBusSupport /JajukDBus org.jajuk.services.dbus.DBusSupport.previous"
  XF86AudioPrev

"dbus-send --session --print-reply --dest=org.jajuk.dbus.DBusSupport /JajukDBus org.jajuk.services.dbus.DBusSupport.stop"
  XF86AudioStop

"dbus-send --session --print-reply --dest=org.jajuk.dbus.DBusSupport /JajukDBus org.jajuk.services.dbus.DBusSupport.playPause"
  XF86AudioPlay

Just starting xbindkeys at the startup maps the keys and allows to use the multimedia keys for controlling Jajuk. The following will add key-combinations for non-audio keyboards, in this case CTRL-ALT-B for _ban_and CTRL-ALT-N for ”show currently playing”:

#ban
"dbus-send --session --print-reply --dest=org.jajuk.dbus.DBusSupport /JajukDBus org.jajuk.services.dbus.DBusSupport.banCurrent"
   m:0xc + c:56
   Control+Alt + b 

#showCurrent
"dbus-send --session --print-reply --dest=org.jajuk.dbus.DBusSupport /JajukDBus org.jajuk.services.dbus.DBusSupport.showCurrentlyPlaying"
   m:0xc + c:57
   Control+Alt + n

Appendix: How to configure key combinations for D-Bus in KDE

Go back to the TOC