aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/tidy/init.lua
blob: ff3b6033a2626e4bbcad0ebf1d67aa51e227e18c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
local awful = require "awful"
local gshape = require "gears.shape"
local gtable = require "gears.table"
local phosphor = require "assets.phosphor"
local q = require "quarrel"
local qcolor = require "quarrel.color"
local qui = require "quarrel.ui"
local qvars = require "quarrel.vars"
local wibox = require "wibox"

local M = {}

M.last_focused_client = nil
M.class_map = {
    ["org.wezfurlong.wezterm"] = "Wezterm",
}

M._popup = qui.popup {
    -- visible = false,
    ontop = true,
    placement = "right",
    shape = function(cr, w, h)
        gshape.partially_rounded_rect(cr, w, h, true, false, false, true, qui.BORDER_RADIUS)
    end,
    -- x = awful.screen.focused().geometry.width,
    -- minimum_width = width,
    -- maximum_width = width,
    -- maximum_height = max_height,
    widget = awful.widget.tasklist {
        screen = awful.screen.focused(),
        filter = awful.widget.tasklist.filter.allscreen,
        source = function(s)
            local ret = gtable.clone(s.all_clients, false)
            -- q.debug(ret)
            table.sort(ret, function(a, b)
                return a.class == b.class and (a.pid or 0) < (b.pid or 0) or a.class < b.class
            end)
            return ret
        end,
        layout = {
            spacing = qui.BIG_PADDING,
            layout = wibox.layout.fixed.vertical,
        },
        widget_template = qui.styled {
            widget = wibox.container.background,
            bg = qcolor.palette.bg.high,
            qui.padded_big {
                {
                    widget = wibox.container.place,
                    {
                        widget = wibox.container.constraint,
                        strategy = "max",
                        height = qui.CHAR_HEIGHT,
                        width = qui.CHAR_HEIGHT,
                        {
                            widget = wibox.widget.imagebox,
                            id = "icon_role",
                        },
                    },
                },
                {
                    widget = wibox.container.constraint,
                    strategy = "max",
                    width = qui.CHAR_WIDTH * 24,
                    {
                        widget = wibox.widget.textbox,
                        id = "client_name",
                    },
                },
                layout = wibox.layout.fixed.horizontal,
                spacing = qui.PADDING,
            },
            create_callback = function(self, c)
                self:get_children_by_id("client_name")[1].text = M.class_map[c.class] or c.class
                if c.active then
                    c.wasactive = true
                    self.border_color = qcolor.palette.yellow()
                end
            end,
            update_callback = function(self, c)
                self:get_children_by_id("client_name")[1].text = M.class_map[c.class] or c.class
                if c.active then
                    c.wasactive = true
                    self.border_color = qcolor.palette.yellow()
                elseif c.wasactive then
                    c.wasactive = false
                    self.border_color = qcolor.palette.border()
                end
            end,
        },
    },
}

return M