Using a dbus service without opening it - python

Tomer Haimovich tomer.ha at gmail.com
Sun Apr 8 09:56:21 PDT 2007


Hi there,

I'm trying to write a python program which will tell me what the Listen
music player is currently playing. I've written this code:

import dbus

bus = dbus.SessionBus()
proxy_obj = bus.get_object( 'org.gnome.Listen', '/org/gnome/listen' )

print proxy_obj.current_playing()

It works well if Listen is already opened when the get_object method is
called, but if Listen is not opened, the script will automatically open it.
I don't want Listen to pop up. If it's not working, I'd rather quit than
open it up. So, I figured that I should do something like this:

bus = dbus.SessionBus()
if listen_is_running():
    proxy_obj = bus.get_object( 'org.gnome.Listen', '/org/gnome/listen' )
    print proxy_obj.current_playing()

Problem is, I don't know how to check if listen is running using DBus.
I've tried to use ps and grep, and it worked well when listen wasn't running
- it just quited, but it doesn't work when listen is running - it just opens
another instance of listen!

So, what am I doing wrong?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20070408/407ba376/attachment.html


More information about the dbus mailing list