dots/.config/awesome/ui/statusbar/widgets/taglist.lua

90 lines
2.8 KiB
Lua

local awful = require "awful"
local vars = require "misc.vars"
local wibox = require "wibox"
local timed = require "lib.rubato".timed
return awful.widget.taglist({
screen = screen[1],
filter = awful.widget.taglist.filter.all,
style = {
shape = vars.shape
},
layout = {
spacing = vars.padding,
layout = wibox.layout.fixed.vertical
},
widget_template = {
{
widget = wibox.container.background,
bg = vars.colors.bright.black,
shape = vars.shape,
forced_height = vars.button_size,
forced_width = vars.button_size,
id = "indicator_role"
},
widget = wibox.container.place,
create_callback = function(self, tag)
local indicator = self:get_children_by_id("indicator_role")[1]
self._anim = timed {
duration = vars.anim_duration,
intro = vars.anim_intro,
pos = indicator.height,
subscribed = function(pos)
indicator.forced_height = pos
end
}
if tag.selected then
indicator.bg = vars.colors.yellow
self._anim.target = vars.button_size * 2
elseif next(tag:clients()) then
indicator.bg = vars.colors.bright.black
self._anim.target = vars.button_size * 1.5
else
self._anim.target = vars.button_size
end
self:connect_signal("mouse::enter", function()
if tag.selected then return end
indicator.bg = vars.colors.yellow
end)
self:connect_signal("mouse::leave", function()
if tag.selected then return end
if next(tag:clients()) then
indicator.bg = vars.colors.bright.black
return
end
indicator.bg = vars.colors.bright.black
end)
end,
update_callback = function(self, tag)
local indicator = self:get_children_by_id("indicator_role")[1]
if tag.selected then
indicator.bg = vars.colors.yellow
self._anim.target = vars.button_size * 2
elseif next(tag:clients()) then
indicator.bg = vars.colors.bright.black
self._anim.target = vars.button_size * 1.5
else
indicator.bg = vars.colors.bright.black
self._anim.target = vars.button_size
end
end
},
buttons = {
awful.button({ }, 1, function(t) t:view_only() end),
awful.button(vars.mods.M, 1, function(t)
if client.focus then
client.focus:move_to_tag(t)
end
end),
awful.button({ }, 3, awful.tag.viewtoggle),
}
})