aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/statusbar/init.lua
blob: 01d6498fdcca37fedfd9802b0ff622bc257acf83 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
local awful = require "awful"
local beautiful = require "beautiful"
local qvars = require "quarrel.vars"
local wibox = require "wibox"
local qui = require "quarrel.ui"
local gcolor = require "gears.color"
local gdebug = require "gears.debug"
local phosphor = require "assets.phosphor"
local qbind = require "quarrel.bind"
local q = require "quarrel"
local rubato = require "lib.rubato"

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

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 = {
            {
                nil,
                {
                    {
                        expand_button,
                        taglist,
                        layout = wibox.layout.fixed.vertical,
                        spacing = qvars.padding * 2,
                    },
                    nil,
                    {
                        widget = wibox.container.place,
                        valign = "bottom",
                        {
                            brightness,
                            battery,
                            wifi,
                            {
                                widget = wibox.container.place,
                                keyboardlayout
                            },
                            clock,
                            layout = wibox.layout.fixed.vertical,
                            spacing = qvars.padding * 2
                        },
                    },
                    layout = wibox.layout.align.vertical,
                    expand = "outside",
                },
                nil,
                layout = wibox.layout.align.horizontal
            },
            nil,
            nil,
            layout = wibox.layout.align.horizontal,
        }
    }

    local bar_width = bar.width

    bar:struts {
        -- left = qvars.bar_size + qvars.big_padding * 2 + beautiful.useless_gap * 4
        -- left = qvars.bar_size + qvars.border_width * 2 + beautiful.useless_gap * 4
        left = bar_width + qvars.border_width * 2 + 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 = wibox.widget {
                    {
                        widget = wibox.container.margin,
                        margins = {
                            left = qvars.big_padding
                        }
                    },
                    {
                        widget = wibox.container.constraint,
                        width = qvars.bar_size * 6,
                        strategy = "min",
                        {
                            {
                                {
                                    widget = wibox.container.background,
                                    bg = qvars.colors.black,
                                    {
                                        widget = wibox.widget.textbox,
                                        text = "1"
                                    }
                                },
                                {
                                    widget = wibox.container.background,
                                    bg = qvars.colors.black,
                                    {
                                        widget = wibox.widget.textbox,
                                        text = "2"
                                    }
                                },
                                {
                                    widget = wibox.container.background,
                                    bg = qvars.colors.black,
                                    {
                                        widget = wibox.widget.textbox,
                                        text = "3"
                                    }
                                },
                                spacing = qvars.padding,
                                layout = wibox.layout.flex.horizontal
                            },
                            layout = wibox.layout.fixed.vertical
                        }
                    },
                    layout = wibox.layout.fixed.horizontal
                }
                bar.ontop = true
            elseif pos == bar_width and not expand_button._expanded then
                bar.widget.widget.third = nil
                bar.ontop = false
            end

            bar.maximum_width = pos
        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)