On Mon, 12 May 2008 19:19:05 -0700, Jimmy wrote:

> Well, i know it may be a little non-python thing, however, I can think
> of no place better to post this question :)
> 
> can anyone tell me, in python, how to obtain some information of a
> running program?
> paticularly, if i am playing some music in audacious or other media
> player, how can i get the the name and some other info of current
> playing song? It seems that audicious doesn't output on run-time

In case of Audatious running on X11 all you need is Python X library
http://python-xlib.sourceforge.net/

And something like:

from Xlib import display

dpy = display.Display()
root = dpy.screen().root

NET_WM_NAME = dpy.intern_atom('_NET_WM_NAME')
UTF8_STRING = dpy.intern_atom('UTF8_STRING')

for win in root.query_tree().children:
    try:
        window_title = win.get_full_property(NET_WM_NAME, 
UTF8_STRING).value
    except AttributeError:
        continue
    if window_title.endswith('Audacious'):
        song = window_title.split(' - ')[:-1]
        if song:
            print song

-- Ivan
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to