-
Notifications
You must be signed in to change notification settings - Fork 242
/
top-panel.lua
121 lines (112 loc) · 2.42 KB
/
top-panel.lua
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
local awful = require('awful')
local beautiful = require('beautiful')
local wibox = require('wibox')
local TaskList = require('widget.task-list')
local gears = require('gears')
local clickable_container = require('widget.material.clickable-container')
local mat_icon_button = require('widget.material.icon-button')
local mat_icon = require('widget.material.icon')
local dpi = require('beautiful').xresources.apply_dpi
local icons = require('theme.icons')
local add_button = mat_icon_button(mat_icon(icons.plus, dpi(24)))
add_button:buttons(
gears.table.join(
awful.button(
{},
1,
nil,
function()
awful.spawn(
awful.screen.focused().selected_tag.defaultApp,
{
tag = _G.mouse.screen.selected_tag,
placement = awful.placement.bottom_right
}
)
end
)
)
)
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
local LayoutBox = function(s)
local layoutBox = clickable_container(awful.widget.layoutbox(s))
layoutBox:buttons(
awful.util.table.join(
awful.button(
{},
1,
function()
awful.layout.inc(1)
end
),
awful.button(
{},
3,
function()
awful.layout.inc(-1)
end
),
awful.button(
{},
4,
function()
awful.layout.inc(1)
end
),
awful.button(
{},
5,
function()
awful.layout.inc(-1)
end
)
)
)
return layoutBox
end
local TopPanel = function(s, offset)
local offsetx = 0
if offset == true then
offsetx = dpi(48)
end
local panel =
wibox(
{
ontop = true,
screen = s,
height = dpi(48),
width = s.geometry.width - offsetx,
x = s.geometry.x + offsetx,
y = s.geometry.y,
stretch = false,
bg = beautiful.background.hue_800,
fg = beautiful.fg_normal,
struts = {
top = dpi(48)
}
}
)
panel:struts(
{
top = dpi(48)
}
)
panel:setup {
layout = wibox.layout.align.horizontal,
{
layout = wibox.layout.fixed.horizontal,
-- Create a taglist widget
TaskList(s),
add_button
},
nil,
{
layout = wibox.layout.fixed.horizontal,
-- Layout box
LayoutBox(s)
}
}
return panel
end
return TopPanel