6 mpd.lua - wmiirc-lua plugin for monitoring and controlling mpd (music player daemon)
10 -- in your wmiirc.lua:
11 wmii.load_plugin("cpu")
22 Jan-David Quesel <jdq@gmx.net>
24 =head1 LICENCE AND COPYRIGHT
26 Copyright (c) 2008, Jan-David Quesel <jdq@gmx.net>
28 This is free software. You may redistribute copies of it under the terms of
29 the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>. There
30 is NO WARRANTY, to the extent permitted by law.
34 local wmii
= require("wmii")
35 local io
= require("io")
36 local os
= require("os")
37 local string = require("string")
38 local tonumber = tonumber
43 -- ------------------------------------------------------------
44 -- Configuration Settings
45 wmii
.set_conf ("mpd.server", "127.0.0.1")
46 wmii
.set_conf ("mpd.port", "6600")
48 -- ------------------------------------------------------------
50 local widget
= wmii
.widget
:new ("301_mpd_status")
52 local function _command ( cmd
)
55 wmii
.log( "about to run " .. cmd
)
56 local file
= io
.popen( cmd
)
57 local status
= file
:read("*a")
60 return status
:match("[^\n]*")
66 local function update_mpd_status (time_since_update
)
67 local printout
= _command("export MPD_HOST=" .. wmii
.get_conf("mpd.server") .. "&& export MPD_PORT=" .. wmii
.get_conf("mpd.port") .. " && mpc")
74 _command("export MPD_HOST=" .. wmii
.get_conf("mpd.server") .. "&& export MPD_PORT=" .. wmii
.get_conf("mpd.port") .. " && mpc next")
79 _command("export MPD_HOST=" .. wmii
.get_conf("mpd.server") .. "&& export MPD_PORT=" .. wmii
.get_conf("mpd.port") .. " && mpc prev")
83 function toggle_pause()
84 _command("export MPD_HOST=" .. wmii
.get_conf("mpd.server") .. "&& export MPD_PORT=" .. wmii
.get_conf("mpd.port") .. " && mpc toggle")
89 _command("export MPD_HOST=" .. wmii
.get_conf("mpd.server") .. "&& export MPD_PORT=" .. wmii
.get_conf("mpd.port") .. " && mpc stop")
93 local timer
= wmii
.timer
:new (update_mpd_status
, 1)