1 local mpc = require("widgets/mpc")
2 local textbox = require("wibox.widget.textbox")
3 local timer = require("gears.timer")
7 local function update_widget()
9 if state == "pause" then
12 text = text .. tostring(artist or "") .. " - " .. tostring(title or "")
13 mpd_widget.text = text
17 local function error_handler(err)
18 mpd_widget:set_text("Error: " .. tostring(err))
19 timer.start_new(10, function()
20 connection:send("ping")
24 connection = mpc.new(nil, nil, nil, error_handler,
25 "status", function(_, result)
28 "currentsong", function(_, result)
29 title, artist, file = result.title, result.artist, result.file
34 mpd_widget:buttons(gears.table.join(
35 awful.button({}, 1, function() connection:toggle_play() end)
36 , awful.button({}, 4, function() connection:change_volume(5) end)
37 , awful.button({}, 5, function() connection:change_volume(-5) end))
40 globalkeys = gears.table.join(globalkeys,
41 awful.key({ modkey }, "p", function() connection:toggle_play() end,
42 { description = "toogle play", group = "mpd" }),
43 awful.key({ modkey }, ",", function() connection:send("previous") end,
44 { description = "previous track", group = "mpd" }),
45 awful.key({ modkey }, ".", function() connection:send("next") end,
46 { description = "next track", group = "mpd" })