local P = {} P.__index = P function P:set_value(value) -- Set widget value. (0 - 100) self.bar.value = value end function P:set_state(state) -- Set widget value. (0 - 100) if (state == "error") then return elseif (state == "muted") then return elseif (state == "unmuted") then return end end function P:set_tooltip(text) -- Set widget value. (0 - 100) self.tooltip.text = text end function P:new() local widget = {} setmetatable(widget, self) widget.bar = wibox.widget { max_value = 100, value = 0, --forced_height = 20, forced_width = beautiful.dpi(50), paddings = 0, border_width = 0, color = { type = "linear", from = {0, 0}, to = {beautiful.dpi(50), 0}, stops = { { 0, "#27D4CC" }, { 1, "#00446B" }} }, background_color = "#FFFFFF30", widget = wibox.widget.progressbar, shape = gears.shape.rounded_bar, } widget.widget = wibox.widget { { { -- Right space widget = wibox.widget.separator, color = beautiful.color.transparent, forced_width = beautiful.dpi(3) }, { widget.bar, top = beautiful.dpi(2), bottom = beautiful.dpi(2), layout = wibox.container.margin, }, { -- Left space widget = wibox.widget.separator, color = beautiful.color.transparent, forced_width = beautiful.dpi(3) }, layout = wibox.layout.align.horizontal, }, layout = wibox.container.background, } widget.tooltip = awful.tooltip { objects = { widget.widget }, text = "" } 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