X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/7584d13fc11bb519ba09528c9fb132a31474a31c..cf2c44249973125a51c370311e7361d9c1e84771:/widgets/mpd.lua diff --git a/widgets/mpd.lua b/widgets/mpd.lua index 6a327b0..c9b3de5 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -14,19 +14,19 @@ local escape_f = require("awful.util").escape local naughty = require("naughty") local wibox = require("wibox") -local os = { execute = os.execute, - getenv = os.getenv } -local math = { floor = math.floor } +local os = { execute = os.execute, + getenv = os.getenv } +local math = { floor = math.floor } local mouse = mouse -local string = { format = string.format, - match = string.match, - gmatch = string.gmatch } +local string = { format = string.format, + match = string.match, + gmatch = string.gmatch } local setmetatable = setmetatable -- MPD infos -- lain.widgets.mpd -local mpd = {} +local mpd = helpers.make_widget_textbox() local function worker(args) local args = args or {} @@ -46,8 +46,6 @@ local function worker(args) local mpdh = "telnet://" .. host .. ":" .. port local echo = echo_cmd .. " 'password " .. password .. "\nstatus\ncurrentsong\nclose'" - mpd.widget = wibox.widget.textbox('') - mpd_notification_preset = { title = "Now playing", timeout = 6 @@ -70,6 +68,8 @@ local function worker(args) artist = "N/A", title = "N/A", album = "N/A", + genre = "N/A", + track = "N/A", date = "N/A", time = "N/A", elapsed = "N/A" @@ -83,6 +83,8 @@ local function worker(args) elseif k == "Artist" then mpd_now.artist = escape_f(v) elseif k == "Title" then mpd_now.title = escape_f(v) elseif k == "Album" then mpd_now.album = escape_f(v) + elseif k == "Genre" then mpd_now.genre = escape_f(v) + elseif k == "Track" then mpd_now.track = escape_f(v) elseif k == "Date" then mpd_now.date = escape_f(v) elseif k == "Time" then mpd_now.time = v elseif k == "elapsed" then mpd_now.elapsed = string.match(v, "%d+") @@ -135,7 +137,7 @@ local function worker(args) helpers.newtimer("mpd", timeout, mpd.update) - return setmetatable(mpd, { __index = mpd.widget }) + return mpd end return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })