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
  • Save whilei/dfef9b0e89a8d8b73ca2a96fb7367f13 to your computer and use it in GitHub Desktop.
Save whilei/dfef9b0e89a8d8b73ca2a96fb7367f13 to your computer and use it in GitHub Desktop.

Revisions

  1. @intrntbrn intrntbrn revised this gist Jun 18, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fancy_taglist.lua
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    -- s.mytaglist = fancy_taglist.new({ screen = s })
    -- ...
    -- end)
    -- 3. Add s.mytaglist to your wibar.
    -- 3. Add s.mytaglist to your wibar.

    local awful = require("awful")
    local wibox = require("wibox")
  2. @intrntbrn intrntbrn created this gist Jun 18, 2020.
    93 changes: 93 additions & 0 deletions fancy_taglist.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,93 @@
    -- 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