aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/statusbar/init.lua
blob: 77a28f7914d9678fa57fa3eeab508ef0d7cff6e0 (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
local awful = require "awful"
local beautiful = require "beautiful"
local panel = require "ui.statusbar.panel"
local phosphor = require "assets.phosphor"
local qstore = require "quarrel.store"
local qui = require "quarrel.ui"
local qvars = require "quarrel.vars"
local rubato = require "lib.rubato"
local wibox = require "wibox"

local clock = require "ui.statusbar.widgets.clock"
local displays = require "ui.statusbar.widgets.displays"
local keyboardlayout = require "ui.statusbar.widgets.keyboardlayout"
local taglist = require "ui.statusbar.widgets.taglist"
local tasklist = require "ui.statusbar.widgets.tasklist"

screen.connect_signal("request::desktop_decoration", function(s)
    local bar = qui.popup {
        placement = function(d)
            return awful.placement.left(d, {
                margins = beautiful.useless_gap * 2,
            })
        end,
        minimum_height = s.geometry.height - (beautiful.useless_gap * 4 + qvars.border_width * 2),
        widget = {
            {
                {
                    taglist(s),
                    layout = wibox.layout.fixed.vertical,
                    spacing = qvars.padding * 2,
                    id = "top",
                },
                nil,
                -- tasklist(s),
                {
                    widget = wibox.container.place,
                    valign = "bottom",
                    {
                        displays.brightness,
                        displays.audio,
                        displays.battery,
                        displays.wifi,
                        {
                            widget = wibox.container.place,
                            {
                                widget = wibox.container.constraint,
                                height = qvars.char_height,
                                width = qvars.char_height,
                                keyboardlayout,
                            },
                        },
                        clock,
                        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 panel_width
    local panel_toggle = { toggled = false } -- hacky but it works

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

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

    panel_toggle = qui.toggle {
        off = phosphor.arrows_out_simple_fill,
        on = phosphor.arrows_in_simple_fill,
        press = function(self)
            if not self.toggled then
                timed.target = bar_width
            else
                timed.target = bar_width + qvars.expanded_bar_size
            end
        end,
    }

    bar.widget:get_children_by_id("top")[1]:insert(1, panel_toggle)
    qstore.panel_toggle = panel_toggle
end)