aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/statusbar/init.lua
blob: e923473164be1b7cc6b5e4d14dac280a42031555 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
local awful = require "awful"
local beautiful = require "beautiful"
local gcolor = require "gears.color"
local panel = require "ui.statusbar.panel"
local phosphor = require "assets.phosphor"
local qbind = require "quarrel.bind"
local qui = require "quarrel.ui"
local qvars = require "quarrel.vars"
local rubato = require "lib.rubato"
local wibox = require "wibox"

local battery = require "ui.statusbar.widgets.battery"
local brightness = require "ui.statusbar.widgets.brightness"
local clock = require "ui.statusbar.widgets.clock"
local keyboardlayout = require "ui.statusbar.widgets.keyboardlayout"
local taglist = require "ui.statusbar.widgets.taglist"
local wifi = require "ui.statusbar.widgets.wifi"

screen.connect_signal("request::desktop_decoration", function(s)
    local expand_button = wibox.widget {
        widget = wibox.container.place,
        valign = "center",
        halign = "center",
        {
            widget = wibox.widget.imagebox,
            image = gcolor.recolor_image(phosphor.caret_right_fill, qvars.colors.fg),
            forced_width = qvars.icon_size,
            forced_height = qvars.icon_size
        },
        _expanded = false
    }

    local bar = qui.popup {
        placement = function(d)
            local place = awful.placement.left
            return place(d, {
                margins = beautiful.useless_gap * 2
            })
        end,
        minimum_height = s.geometry.height - (beautiful.useless_gap * 4 + qvars.border_width * 2),
        widget = {
            {
                {
                    expand_button,
                    taglist,
                    layout = wibox.layout.fixed.vertical,
                    spacing = qvars.padding * 2,
                },
                nil,
                {
                    widget = wibox.container.place,
                    valign = "bottom",
                    {
                        {
                            widget = wibox.container.place,
                            keyboardlayout
                        },
                        clock,
                        wifi,
                        brightness,
                        battery,
                        layout = wibox.layout.fixed.vertical,
                        spacing = qvars.padding * 2
                    },
                },
                layout = wibox.layout.align.vertical,
                expand = "outside",
            },
            nil,
            nil,
            layout = wibox.layout.align.horizontal,
        }
    }

    local bar_width = bar.width + qvars.border_width * 2

    bar:struts {
        left = bar_width + beautiful.useless_gap * 4
    }

    local timed = rubato.timed {
        duration = qvars.anim_duration,
        intro = qvars.anim_intro,
        pos = bar_width,
        subscribed = function(pos)
            if pos ~= bar_width and expand_button._expanded then
                bar.widget.widget.third = panel
                bar.ontop = true
            elseif pos == bar_width and not expand_button._expanded then
                bar.widget.widget.third = nil
                bar.ontop = false
            end

            bar.shape = function(cr, _, h)
                qvars.shape(cr, pos, h)
            end
        end
    }

    expand_button.buttons = {
        qbind:new {
            triggers = qvars.btns.left,
            press = function()
                if expand_button._expanded then
                    timed.target = bar_width
                else
                    timed.target = bar_width + qvars.bar_size * 6
                end

                expand_button._expanded = not expand_button._expanded
            end,
            hidden = true
        }
    }
end)