Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Names require service files to call methods #9

Open
acrisci opened this issue Sep 24, 2014 · 2 comments
Open

Names require service files to call methods #9

acrisci opened this issue Sep 24, 2014 · 2 comments

Comments

@acrisci
Copy link

acrisci commented Sep 24, 2014

Hello, I am not a dbus expert so forgive me if this is programmer error.

I am following the examples and I want to call a method like could be executed from the command line like so:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

which should make my media player play.

Here is a program that I would expect to do this with godbus:

package main

import (
    "github.com/godbus/dbus"
)

func main() {
    conn, err := dbus.SessionBus()
    if err != nil {
        panic(err)
    }
    obj := conn.Object("org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2")
    call := obj.Call("org.mpris.MediaPlayer2.Player.PlayPause", 0)
    if call.Err != nil {
        panic(call.Err)
    }
}

But I get this error:

panic: The name org.mpris.MediaPlayer2.vlc was not provided by any .service files

with a stack trace. I believe it is correct that there is not any such service file that provides org.mpris.MediaPlayer2.vlc, but vlc is running, and when I list names with dbus-send, it appears in the returned array. However, when I run the example in the examples folder to list names, it does not appear in the returned array.

Could someone help me out with this?

Thanks.

@alexlarsson
Copy link
Contributor

It sounds to me like the your app and dbus-send are talking to different instances of the dbus daemon. Do they get the same DBUS_SESSION_BUS_ADDRESS env var passed in?

@acrisci
Copy link
Author

acrisci commented Sep 24, 2014

Thanks for the hint. The problem does seem to be related to the fact that the example I provided is talking to a different instance of the dbus daemon.

Without setting DBUS_SESSION_BUS_ADDRESS in the env, dbus-send and the library seem to be choosing different addresses.

The address dbus-send is using can be found by examining the file ~/.dbus/session-bus/[machine id]-[X display]. If I set DBUS_SESSION_BUS_ADDRESS to the address indicated by this file, the library will work as I expect it to and find the vlc name.

I'm not exactly sure what heuristic to use in general to find the "correct" bus address.

I think that the fact that dbus-send is using a different method to find the address could be considered a bug. I have also tried creating a simple dbus service with a python library and the address agrees with dbus-send. Should I file another ticket for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants