-
Notifications
You must be signed in to change notification settings - Fork 0
/
titlebar.lua
153 lines (143 loc) · 6.16 KB
/
titlebar.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
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
local awful = require("awful")
local wibox = require("wibox")
local gears = require("gears")
-- local titlebar_tb = {}
local home_dir = os.getenv("HOME")
local function titlebar(c)
local top_titlebar = awful.titlebar(c, {
size = 26,
bg = "#00000099",
bg_normal = '#ff000000',
bg_active = '#00ffff',
bg_unfocus = "#ff00ff",
})
-- close button
local closebtn = wibox.widget {
image = gears.color.recolor_image(home_dir .. "/.config/awesome/icons/close_shuriken.svg", "#000000"),
widget = wibox.widget.imagebox,
}
closebtn:connect_signal("button::press", function()
c:kill()
end)
closebtn:connect_signal("mouse::enter", function()
closebtn.image = gears.color.recolor_image(home_dir .. "/.config/awesome/icons/close_shuriken.svg", "#ffffff")
end)
closebtn:connect_signal("mouse::leave", function()
closebtn.image = gears.color.recolor_image(home_dir .. "/.config/awesome/icons/close_shuriken.svg", "#000000")
end)
-- minimize and maximize button is here
local maxbtn = wibox.widget {
image = gears.color.recolor_image(home_dir .. "/.config/awesome/icons/maximize.svg", "#000000"),
widget = wibox.widget.imagebox,
}
maxbtn:connect_signal("button::press", function()
c.maximized = not c.maximized
end)
maxbtn:connect_signal("mouse::enter", function()
maxbtn.image = gears.color.recolor_image(home_dir .. "/.config/awesome/icons/maximize.svg", "#ffffff")
end)
maxbtn:connect_signal("mouse::leave", function()
maxbtn.image = gears.color.recolor_image(home_dir .. "/.config/awesome/icons/maximize.svg", "#000000")
end)
-- always on top feature is here
local alwaysontop = wibox.widget {
image = gears.color.recolor_image(home_dir .. "/.config/awesome/icons/ontop.svg", "#000000"),
widget = wibox.widget.imagebox,
}
alwaysontop:connect_signal("button::press", function()
c.ontop = not c.ontop
end)
alwaysontop:connect_signal("mouse::enter", function()
alwaysontop.image = gears.color.recolor_image(home_dir .. "/.config/awesome/icons/ontop.svg", "#ffffff")
end)
alwaysontop:connect_signal("mouse::leave", function()
alwaysontop.image = gears.color.recolor_image(home_dir .. "/.config/awesome/icons/ontop.svg", "#000000")
end)
local buttons = gears.table.join(
awful.button({}, 1, function()
c:emit_signal("request::activate", "titlebar", { raise = true })
awful.mouse.client.move(c)
end),
awful.button({}, 3, function()
c:emit_signal("request::activate", "titlebar", { raise = true })
awful.mouse.client.resize(c)
end)
)
top_titlebar:setup {
{
{
wibox.container.margin(awful.titlebar.widget.iconwidget(c), 20, 20, 3, 3),
buttons = buttons,
layout = wibox.layout.fixed.horizontal
},
{
{
{
align = "center",
widget = awful.titlebar.widget.titlewidget(c),
font = "KodeMono 10",
},
widget = wibox.container.margin,
margins = { top = 0, bottom = 0 }
},
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{
{
widget = wibox.widget.background,
bg = "#00000000",
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 10)
end,
forced_width = 100,
{
{
widget = wibox.container.margin,
margins = { left = 6, right = 6, top = 2, bottom = 2 },
{
widget = wibox.widget.background,
bg = "#00ca4e9cc",
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 100)
end,
wibox.container.place(wibox.container.margin(alwaysontop, 4, 4, 4, 4), "center", "center"),
}
},
{
widget = wibox.container.margin,
margins = { left = 6, right = 6, top = 2, bottom = 2 },
{
widget = wibox.widget.background,
bg = "#ffbd44cc",
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 100)
end,
wibox.container.place(wibox.container.margin(maxbtn, 4, 4, 4, 4), "center", "center"),
}
},
{
widget = wibox.container.margin,
margins = { left = 6, right = 6, top = 2, bottom = 2 },
{
widget = wibox.widget.background,
bg = "#ff605ccc",
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 100)
end,
wibox.container.place(wibox.container.margin(closebtn, 4, 4, 4, 4), "center", "center"),
}
},
layout = wibox.layout.flex.horizontal
}
},
widget = wibox.container.margin,
margins = { top = 0, bottom = 0, left = 20, right = 0 }
},
layout = wibox.layout.align.horizontal
},
widget = wibox.widget.background,
bg = "#ffffff33",
}
end
return titlebar