Skip to content

Instantly share code, notes, and snippets.

@whilei
Forked from intrntbrn/fancy_taglist.lua
Created May 27, 2021 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save whilei/dfef9b0e89a8d8b73ca2a96fb7367f13 to your computer and use it in GitHub Desktop.
Save whilei/dfef9b0e89a8d8b73ca2a96fb7367f13 to your computer and use it in GitHub Desktop.
awesomewm fancy_taglist: a taglist that contains a tasklist for each tag
-- awesomewm fancy_taglist: a taglist that contains a tasklist for each tag.
-- Usage:
-- 1. Save as "fancy_taglist.lua" in ~/.config/awesome
-- 2. Add a fancy_taglist for every screen:
-- awful.screen.connect_for_each_screen(function(s)
-- ...
-- local fancy_taglist = require("fancy_taglist")
-- s.mytaglist = fancy_taglist.new({ screen = s })
-- ...
-- end)
-- 3. Add s.mytaglist to your wibar.
local awful = require("awful")
local wibox = require("wibox")
local module = {}
local generate_filter = function(i)
return function(c, scr)
local t = scr.tags[i]
local ctags = c:tags()
for _, v in ipairs(ctags) do
if v == t then
return true
end
end
return false
end
end
local fancytasklist = function(cfg, tag_index)
return awful.widget.tasklist{
screen = cfg.screen or awful.screen.focused(),
filter = generate_filter(tag_index),
buttons = cfg.tasklist_buttons,
widget_template = {
{
id = "clienticon",
widget = awful.widget.clienticon
},
layout = wibox.layout.stack,
create_callback = function(self, c, _, _)
self:get_children_by_id("clienticon")[1].client = c
awful.tooltip{
objects = { self },
timer_function = function()
return c.name
end
}
end
}
}
end
function module.new(config)
local cfg = config or {}
local s = cfg.screen or awful.screen.focused()
local taglist_buttons = cfg.taglist_buttons
return awful.widget.taglist{
screen = s,
filter = awful.widget.taglist.filter.all,
widget_template = {
{
{
-- tag
{
id = "text_role",
widget = wibox.widget.textbox,
align = "center"
},
-- tasklist
{
id = "tasklist_placeholder",
layout = wibox.layout.fixed.horizontal
},
layout = wibox.layout.fixed.horizontal
},
id = "background_role",
widget = wibox.container.background
},
layout = wibox.layout.fixed.horizontal,
create_callback = function(self, _, index, _)
self:get_children_by_id("tasklist_placeholder")[1]:add(fancytasklist(cfg, index))
end
},
buttons = taglist_buttons
}
end
return module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment