File: statusd_xmms.lua

package info (click to toggle)
notion 4.0.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,676 kB
  • sloc: ansic: 47,508; sh: 2,096; makefile: 603; perl: 270
file content (44 lines) | stat: -rw-r--r-- 1,140 bytes parent folder | download | duplicates (6)
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
35
36
37
38
39
40
41
42
43
44
-- Authors: Peter Randeu <ranpet@sbox.tugraz.at>
-- License: GPL, version 2
-- Last Changed: Unknown
--
-- statusd_xmms.lua
--
-- Gets title of song currently selected in xmms' playlist.
-- Depends on xmms and pyxmms-remote
-- Inspired by statusd_mpd.lua
-- Written by Peter Randeu < ranpet at sbox dot tugraz dot at >
--
-- You are free to distribute this software under the terms of the GNU
-- General Public License Version 2.

if not statusd_xmms then
  statusd_xmms={
      interval=10*1000,
  }
end

local settings = table.join (statusd.get_config("xmms"), statusd_xmms)

local function get_xmms_status()
      local f = io.popen('pyxmms-remote get_playlist_pos', 'r')
      local pl_num = f:read()
      if not pl_num then
          return "pyxmms-remote not available"
      end
      f:close()
      f = io.popen('pyxmms-remote get_playlist_title ' .. pl_num, 'r')
      title = f:read()
      f:close()
      return title
end

local xmms_timer

local function update_xmms()
      statusd.inform("xmms", get_xmms_status())
      xmms_timer:set(settings.interval, update_xmms)
end

xmms_timer = statusd.create_timer()
update_xmms()