156 lines
3.5 KiB
Lua
156 lines
3.5 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.popup_widget = wibox.widget {
|
|
text = "A popup",
|
|
--forced_height = 100,
|
|
widget = wibox.widget.textbox
|
|
}
|
|
|
|
widget.popup = awful.popup {
|
|
widget = widget.popup_widget,
|
|
border_color = "#00ff00",
|
|
border_width = 0,
|
|
placement = function(client)
|
|
return awful.placement.next_to(client, {
|
|
honor_workarea = true,
|
|
preferred_positions = "top",
|
|
preferred_anchors = "front",
|
|
})
|
|
end,
|
|
shape = gears.shape.rounded_rect,
|
|
visible = false,
|
|
ontop = true
|
|
}
|
|
|
|
widget.widget:connect_signal("mouse::enter", function(result)
|
|
widget.widget.bg = beautiful.color.bar.hover_bg
|
|
--widget.popup.visible = true
|
|
widget.popup:move_next_to(result)
|
|
widget.popup_widget.text = "t"
|
|
--debug_message(result)
|
|
end)
|
|
|
|
widget.widget:connect_signal("mouse::leave", function(result)
|
|
widget.widget.bg = beautiful.color.transparent
|
|
widget.popup.visible = false
|
|
end)
|
|
|
|
return widget
|
|
end
|
|
|
|
return P
|