Mercurial > audlegacy
annotate contrib/xchat-audacious.py @ 2740:a67712c75069 trunk
[svn] - add an xchat script which wraps our DBus API using dbus-python.
author | nenolod |
---|---|
date | Fri, 11 May 2007 17:20:46 -0700 |
parents | |
children | 96e7c0385973 |
rev | line source |
---|---|
2740
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
1 # |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
2 # X-Chat Audacious for Audacious 1.4 and later |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
3 # This uses the native Audacious D-Bus interface. |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
4 # |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
5 # To consider later: |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
6 # - support org.freedesktop.MediaPlayer (MPRIS)? |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
7 # |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
8 |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
9 __module_name__ = "xchat-audacious" |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
10 __module_version__ = "1.0" |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
11 __module_description__ = "Get NP information from Audacious" |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
12 |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
13 from dbus import Bus, Interface |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
14 import xchat |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
15 |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
16 # connect to DBus |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
17 bus = Bus(Bus.TYPE_SESSION) |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
18 |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
19 def command_np(word, word_eol, userdata): |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
20 aud = bus.get_object('org.atheme.audacious', '/org/atheme/audacious') |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
21 |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
22 # this seems to be best, probably isn't! |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
23 length = "stream" |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
24 if aud.SongLength(aud.Position()) > 0: |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
25 length = "%d:%02d" % (aud.SongLength(aud.Position()) / 60, |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
26 aud.SongLength(aud.Position()) % 60) |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
27 |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
28 xchat.command("SAY [%s | %d:%02d/%s]" % ( |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
29 aud.SongTitle(aud.Position()), |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
30 aud.Time() / 1000 / 60, aud.Time() / 1000 % 60, |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
31 length)) |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
32 |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
33 return xchat.EAT_ALL |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
34 |
a67712c75069
[svn] - add an xchat script which wraps our DBus API using dbus-python.
nenolod
parents:
diff
changeset
|
35 xchat.hook_command("NP", command_np, help="Displays current playing song.") |