2022-04-24 12:22:44 -07:00
|
|
|
local P = {}
|
2022-04-24 12:27:54 -07:00
|
|
|
P.__index = P
|
2022-04-24 12:22:44 -07:00
|
|
|
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-16 21:26:41 -07:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-04-24 12:22:44 -07:00
|
|
|
widget.widget:connect_signal("mouse::enter", function(result)
|
|
|
|
widget.widget.bg = beautiful.color.bar.hover_bg
|
2022-07-16 21:26:41 -07:00
|
|
|
--widget.popup.visible = true
|
|
|
|
widget.popup:move_next_to(result)
|
|
|
|
widget.popup_widget.text = "t"
|
|
|
|
--debug_message(result)
|
2022-04-24 12:22:44 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
widget.widget:connect_signal("mouse::leave", function(result)
|
|
|
|
widget.widget.bg = beautiful.color.transparent
|
2022-07-16 21:26:41 -07:00
|
|
|
widget.popup.visible = false
|
2022-04-24 12:22:44 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
return widget
|
|
|
|
end
|
|
|
|
|
|
|
|
return P
|