Include notionflux in the main repo instead of its own submodule
[notion/jeffpc.git] / contrib / statusd / statusd_xmms2.lua
blob9b6baa5cb73b924273dff6a1a22ceddb3dec4777
1 -- Authors: Voker57 <voker57@gmail.com>
2 -- License: Public domain
3 -- Last Changed: Unknown
4 --
5 -- Real simple xmms2 monitor
7 -- %xmms2 - current song in format "Artist - Title"
9 -- by Voker57 <voker57@gmail.com>
10 -- Public domain
12 local defaults={
13 -- 500 or less makes seconds increment relatively smoothly while playing
14 update_interval=500
17 local settings=table.join(statusd.get_config("xmms2"), defaults)
19 local xmms2_timer
21 local function get_xmms2_status()
22 local xmms2 = io.popen("xmms2 current")
23 if xmms2 == nil then
24 return nil
25 else
26 local r = ""
27 local t = ""
28 repeat
29 r = r..t
30 t = xmms2:read()
31 until t == nil
32 return r
33 end
34 end
36 local function update_xmms2()
37 local xmms2_st = get_xmms2_status()
38 statusd.inform("xmms2", xmms2_st)
39 xmms2_timer:set(settings.update_interval, update_xmms2)
40 end
42 -- Init
43 xmms2_timer=statusd.create_timer()
44 update_xmms2()