Skip to content

Instantly share code, notes, and snippets.

@Elv13
Last active October 6, 2016 22:29
Show Gist options
  • Save Elv13/e04e2b0f1e0292eaf7702ff2e6197ddf to your computer and use it in GitHub Desktop.
Save Elv13/e04e2b0f1e0292eaf7702ff2e6197ddf to your computer and use it in GitHub Desktop.
local function powerline_add(self, ...)
local colors,new_widgets, dir, count = self.colors or {
"#0000ff",
"#ff0000",
"#00ff00"
}, {...}, self.direction or "right", #self.children/2
local ridx = (dir=="right" and 1 or -1)
if self.children[count] then self.children[count]:emit_signal("widget::redraw_needed") end
for i=1, #new_widgets do
local color = gears.color(colors[(count%#colors) + 1])
local nextc = gears.color(colors[((count+ridx)%#colors) + 1])
local separator = wibox.widget {
fit = function(self,c,w,h) return h/2,h end,
draw = function(sep, context, cr, w,h)
local children = self:get_children()
local is_edge = (ridx==1 and children[#children] == sep) or
(ridx==-1 and sep==children[1])
if not is_edge then
cr:set_source(nextc)
cr:paint()
end
local begx = dir == "right" and 0 or w
cr:move_to(begx,0)
cr:line_to(begx==0 and w or 0,h/2)
cr:line_to(begx, h)
cr:close_path()
cr:set_source(color)
cr:fill()
end,
widget = wibox.widget.base.make_widget
}
if dir == "left" then self:real_add(separator) end
self:real_add(wibox.container.background(new_widgets[i],color))
if dir == "right" then self:real_add(separator) end
count = count + 1
end
end
local function powerline_layout()
local l = wibox.layout.fixed.horizontal()
rawset(l, "real_add", l.add )
rawset(l, "add" , powerline_add)
return l
end
mywibox[s]:setup{
awful.widget.taglist(
w5.screen,
awful.widget.taglist.filter.all,
taglist_buttons,
{
bg_focus = gears.color.transparent,
bg_empty = gears.color.transparent,
bg_used = gears.color.transparent,
},
nil,
powerline_layout()
),
nil,
{
wibox.widget.textbox "one",
wibox.widget.textbox "two",
wibox.widget.textbox "three",
wibox.widget.textbox "four",
wibox.widget.textbox "five",
direction = "left",
widget = powerline_layout
},
layout = wibox.layout.align.horizontal,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment