129 lines
2.9 KiB
Lua
129 lines
2.9 KiB
Lua
local P = {}
|
|
P.__index = P
|
|
|
|
function P:update(args)
|
|
if (args.error ~= nil) then
|
|
self.title.markup = "MPD is not"
|
|
self.artist.markup = "connected"
|
|
self.volume.markup = "??"
|
|
else
|
|
self.title.markup = args.title or "No track"
|
|
self.artist.markup = args.artist or "loaded"
|
|
|
|
if (args.play) then
|
|
self.icon.image = beautiful.icons.music.blue.playing
|
|
elseif (args.pause) then
|
|
self.icon.image = beautiful.icons.music.blue.paused
|
|
elseif (args.stop) then
|
|
self.icon.image = beautiful.icons.music.blue.stopped
|
|
end
|
|
|
|
if (args.volume) then
|
|
self.volume.markup = args.volume .. "%"
|
|
else
|
|
self.volume.markup = ""
|
|
end
|
|
end
|
|
end
|
|
|
|
function P:new()
|
|
local widget = {}
|
|
setmetatable(widget, self)
|
|
|
|
widget.title = wibox.widget.textbox("MPD is not")
|
|
widget.title.valign = "center"
|
|
widget.title.align = "left"
|
|
widget.title.font = "Hack NF 12"
|
|
widget.title.ellipsize = "end"
|
|
widget.title.forced_width = beautiful.dpi(conf.mpc_width)
|
|
|
|
widget.artist = wibox.widget.textbox("connected")
|
|
widget.artist.valign = "center"
|
|
widget.artist.align = "left"
|
|
widget.artist.font = "Hack NF 12"
|
|
widget.artist.ellipsize = "end"
|
|
widget.artist.forced_width = beautiful.dpi(conf.mpc_width)
|
|
|
|
widget.volume = wibox.widget.textbox("??")
|
|
widget.volume.valign = "center"
|
|
widget.volume.align = "left"
|
|
widget.volume.font = "Hack NF 10"
|
|
widget.volume.ellipsize = "end"
|
|
widget.volume.forced_width = beautiful.dpi(10)
|
|
|
|
|
|
widget.icon = wibox.widget {
|
|
resize = true,
|
|
image = beautiful.icons.music.blue.playing,
|
|
widget = wibox.widget.imagebox
|
|
}
|
|
|
|
widget.left = wibox.widget {
|
|
wibox.widget {
|
|
{
|
|
widget.icon,
|
|
top = beautiful.dpi(2),
|
|
bottom = beautiful.dpi(2),
|
|
left = 0, right = 0,
|
|
layout = wibox.container.margin,
|
|
},
|
|
widget.volume,
|
|
|
|
forced_num_cols = 1,
|
|
forced_num_rows = 2,
|
|
homogeneous = true,
|
|
expand = true,
|
|
layout = wibox.layout.grid
|
|
},
|
|
layout = wibox.container.background
|
|
}
|
|
|
|
widget.right = wibox.widget {
|
|
wibox.widget {
|
|
widget.title,
|
|
widget.artist,
|
|
|
|
forced_num_cols = 1,
|
|
forced_num_rows = 2,
|
|
homogeneous = true,
|
|
expand = true,
|
|
layout = wibox.layout.grid
|
|
},
|
|
layout = wibox.container.background,
|
|
}
|
|
|
|
widget.widget = wibox.widget {
|
|
{
|
|
{ -- Right spacer
|
|
widget = wibox.widget.separator,
|
|
color = beautiful.color.transparent,
|
|
forced_width = beautiful.dpi(3)
|
|
},
|
|
|
|
widget.left,
|
|
widget.right,
|
|
|
|
{ -- Left spacer
|
|
widget = wibox.widget.separator,
|
|
color = beautiful.color.transparent,
|
|
forced_width = beautiful.dpi(3)
|
|
},
|
|
layout = wibox.layout.align.horizontal,
|
|
},
|
|
layout = wibox.container.background,
|
|
}
|
|
|
|
|
|
widget.widget:connect_signal("mouse::enter", function(result)
|
|
widget.widget.bg = beautiful.color.bar.hover_bg
|
|
end)
|
|
|
|
widget.widget:connect_signal("mouse::leave", function(result)
|
|
widget.widget.bg = beautiful.color.transparent
|
|
end)
|
|
|
|
return widget
|
|
end
|
|
|
|
return P
|