Released version 3-2015061300
[notion.git] / contrib / statusd / statusd_xmms.lua
blob0a584ec550f8b37d83949e4c2fd9064b81a8c5bc
1 -- Authors: Peter Randeu <ranpet@sbox.tugraz.at>
2 -- License: GPL, version 2
3 -- Last Changed: Unknown
4 --
5 -- statusd_xmms.lua
6 --
7 -- Gets title of song currently selected in xmms' playlist.
8 -- Depends on xmms and pyxmms-remote
9 -- Inspired by statusd_mpd.lua
10 -- Written by Peter Randeu < ranpet at sbox dot tugraz dot at >
12 -- You are free to distribute this software under the terms of the GNU
13 -- General Public License Version 2.
15 if not statusd_xmms then
16 statusd_xmms={
17 interval=10*1000,
19 end
21 local settings = table.join (statusd.get_config("xmms"), statusd_xmms)
23 local function get_xmms_status()
24 local f = io.popen('pyxmms-remote get_playlist_pos', 'r')
25 local pl_num = f:read()
26 if not pl_num then
27 return "pyxmms-remote not available"
28 end
29 f:close()
30 f = io.popen('pyxmms-remote get_playlist_title ' .. pl_num, 'r')
31 title = f:read()
32 f:close()
33 return title
34 end
36 local xmms_timer
38 local function update_xmms()
39 statusd.inform("xmms", get_xmms_status())
40 xmms_timer:set(settings.interval, update_xmms)
41 end
43 xmms_timer = statusd.create_timer()
44 update_xmms()