local awful = require("awful")
local wibox = require("wibox")
local gears = require("gears")
local awmtk = require("awmtk")
function macbar(s,args)
    local style = awmtk.style(awmtk.defaults,args.style or {},"macbar_")
    s.mymacbar = awful.wibar({
        stretch = false,
        position = "bottom", 
        screen = s,
        border_width = style.macbar_border_width or 1,
        border_color = style.macbar_border_color or "#262626AA",
        bg = style.macbar_bg or ((style.bg_normal:len() < 8) and style.bg_normal.."AA"),
        height = style.macbar_height or 50,
        width = style.macbar_width or 650,
        shape = function(cr,width,height) 
            return gears.shape.partially_rounded_rect(cr,width,height,true,true,false,false,style.macbar_rounding or 5)
        end

    })
    local top_widgets = {
        layout = wibox.layout.fixed.horizontal,
    }
    local bottom_widgets = {
        layout = wibox.layout.fixed.horizontal,
    }
    for _,widget in pairs(args.top_widgets or {}) do
        table.insert(top_widgets,widget)
    end
    for _, widget in pairs(args.bottom_widgets or {}) do
        table.insert(bottom_widgets,widget)
    end
    s.mymacbar:setup {
        widget = wibox.container.margin,
        margins = style.macbar_inner_margin,
        {
            layout = wibox.layout.align.horizontal,
            top_widgets,
            { --Middle spacer
                widget = wibox.container.background
            },
            bottom_widgets
        }
    }
    return s.mymacbar
end
return macbar
