File: statusd_mpd.lua

package info (click to toggle)
ion3-scripts 20050418-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 300 kB
  • ctags: 153
  • sloc: makefile: 18
file content (34 lines) | stat: -rw-r--r-- 536 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


local settings={
    interval=10*1000,
}





local function get_mpd_status()
  os.execute('mpc > /tmp/mpdstats')
  local f=io.open('/tmp/mpdstats','r')
  local playing=f:read()
  if string.sub(playing, 1,7) == 'volume:' then
    return "No song playing"
  else
    return playing
  end
        
end

local mpd_timer

local function update_mpd()
    statusd.inform("mpd", get_mpd_status())
    mpd_timer:set(settings.interval, update_mpd)
end

-- Init
--get_inet_addr=get_inet_addr_fn()
mpd_timer=statusd.create_timer()
update_mpd()