-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen-init.lua
468 lines (444 loc) · 11.9 KB
/
screen-init.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
local net_widgets = require("net_widgets")
local awful = require("awful")
local wibox = require("wibox")
local naughty = require("naughty")
local h = require("helpers")
local u = require("util")
local make_layoutbox
make_layoutbox = function(screen)
local lb = awful.widget.layoutbox(screen)
local buttons = {
awful.button({ }, 1, function()
return awful.layout.inc(1)
end),
awful.button({ }, 3, function()
return awful.layout.inc(-1)
end),
awful.button({ }, 4, function()
return awful.layout.inc(1)
end),
awful.button({ }, 5, function()
return awful.layout.inc(-1)
end)
}
lb:buttons(gears.table.join(unpack(buttons)))
return lb
end
local make_sep
make_sep = function(t)
if t == nil then
t = 1
end
return {
forced_width = 5,
forced_height = 24,
thickness = t,
color = "#777777",
widget = wibox.widget.separator
}
end
local make_tasklist
make_tasklist = function(screen, buttons)
local highlight_bar_widget = {
wibox.widget.base.make_widget(),
forced_height = 5,
id = "background_role",
widget = wibox.container.background
}
local utf8 = require("lua-utf8")
return awful.widget.tasklist({
screen = screen,
buttons = buttons,
filter = awful.widget.tasklist.filter.currenttags,
layout = {
spacing_widget = {
make_sep(),
valign = "center",
halign = "center",
widget = wibox.container.place
},
spacing = 35,
layout = wibox.layout.fixed.horizontal
},
widget_template = {
highlight_bar_widget,
{
{
{
id = "clienticon",
widget = awful.widget.clienticon
},
margins = 5,
widget = wibox.container.margin
},
{
id = "title",
widget = wibox.widget.textbox
},
layout = wibox.layout.align.horizontal
},
nil,
create_callback = function(self, c, index, objects)
self:get_children_by_id("clienticon")[1].client = c
self:get_children_by_id("title")[1].text = tostring(utf8.sub(c.name, 1, 40))
end,
update_callback = function(self, c, index, objects)
self:get_children_by_id("clienticon")[1].client = c
self:get_children_by_id("title")[1].text = tostring(utf8.sub(c.name, 1, 40))
end,
layout = wibox.layout.align.vertical
}
})
end
local get_top
get_top = function()
local f = io.popen("top -b -n1 -w 140")
return table.concat((function()
local _accum_0 = { }
local _len_0 = 1
for line in f:lines() do
_accum_0[_len_0] = line
_len_0 = _len_0 + 1
end
return _accum_0
end)(), "\n")
end
local get_top_mem
get_top_mem = function()
local f = io.popen("top -b -n1 -w 140 -o RES")
return table.concat((function()
local _accum_0 = { }
local _len_0 = 1
for line in f:lines() do
_accum_0[_len_0] = line
_len_0 = _len_0 + 1
end
return _accum_0
end)(), "\n")
end
local make_mem_widget
make_mem_widget = function()
local widget = wibox.widget.textbox()
vicious.register(widget, vicious.widgets.mem, "MEM: $1%")
local notification = nil
widget:connect_signal("mouse::enter", function()
notification = naughty.notify({
text = get_top_mem(),
timeout = 0,
font = "monospace 12",
screen = mouse.screen,
position = naughty.config.defaults.position,
max_width = 1800
})
end)
widget:connect_signal("mouse::leave", function()
if notification ~= nil then
naughty.destroy(notification)
notification = nil
end
end)
return widget
end
local make_cpu_widget
make_cpu_widget = function()
local widget = wibox.widget.textbox()
local format
format = function(w, a)
return "CPU: " .. string.format("%2s", a[1]) .. "%"
end
vicious.register(widget, vicious.widgets.cpu, format, 2)
local notification = nil
widget:connect_signal("mouse::enter", function()
notification = naughty.notify({
text = get_top(),
timeout = 0,
font = "monospace 12",
screen = mouse.screen,
position = naughty.config.defaults.position,
max_width = 1800
})
end)
widget:connect_signal("mouse::leave", function()
if notification ~= nil then
naughty.destroy(notification)
notification = nil
end
end)
return widget
end
local get_sensors
get_sensors = function()
local f = io.popen("sensors")
return table.concat((function()
local _accum_0 = { }
local _len_0 = 1
for line in f:lines() do
_accum_0[_len_0] = line
_len_0 = _len_0 + 1
end
return _accum_0
end)(), "\n")
end
local make_therm_widget
make_therm_widget = function()
local widget = wibox.widget.textbox()
vicious.register(widget, vicious.widgets.thermal, "T: $1℃", 2, "thermal_zone0")
local notification = nil
widget:connect_signal("mouse::enter", function()
notification = naughty.notify({
text = get_sensors(),
timeout = 0,
font = "monospace 12",
screen = mouse.screen,
position = naughty.config.defaults.position,
max_width = 1800
})
end)
widget:connect_signal("mouse::leave", function()
if notification ~= nil then
naughty.destroy(notification)
notification = nil
end
end)
return widget
end
local beautiful = require("beautiful")
local gears = require("gears")
local set_wallpaper
set_wallpaper = function(screen)
return gears.wallpaper.maximized("/home/cji/Pictures/mirai-nikki1.jpg", screen, true)
end
local tasklist_buttons = gears.table.join(
awful.button({ }, 1, function (c)
if c == client.focus then
c.minimized = true
else
c:emit_signal(
"request::activate",
"tasklist",
{raise = true}
)
end
end),
awful.button({ }, 3, function()
awful.menu.client_list({ theme = { width = 250 } })
end),
awful.button({ }, 4, function ()
awful.client.focus.byidx(1)
end),
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
end)
)
local initialize
initialize = function()
screen.connect_signal("property::geometry", set_wallpaper)
return awful.screen.connect_for_each_screen(function(s)
set_wallpaper(s)
awful.tag({"1", "2", "3", "4", "5", "6", "7", "8", "9"}, s, awful.layout.layouts[1])
s.mytaglist = nil -- disable the default one
s.mypromptbox = awful.widget.prompt()
s.mylayoutbox = awful.widget.layoutbox(s)
s.mylayoutbox:buttons(
gears.table.join(
awful.button({ }, 1, function() return awful.layout.inc(1) end),
awful.button({ }, 3, function() return awful.layout.inc(-1) end),
awful.button({ }, 4, function() return awful.layout.inc(1) end),
awful.button({ }, 5, function() return awful.layout.inc(-1) end)
)
)
s.mytasklist = make_tasklist(s, tasklist_buttons)
s.cpuwidget = make_cpu_widget()
s.batwidget = wibox.widget.progressbar()
s.batwidget.forced_width = 50
s.batwidget.forced_height = 3
local batbox = wibox.container.constraint(wibox.widget({
{
max_value = 1,
widget = s.batwidget,
border_width = 0.5,
border_color = "#000000",
color = {
type = "linear",
from = {0, 0},
to = {0, 30},
stops = {{0, "#AECF96"}, {1, "#FF5656"}}
}
},
direction = "east",
color = beautiful.fg_widget,
layout = wibox.container.place
}, "min", 2, 3))
local pbar = wibox.widget({
max_value = 1,
color = "#AECF96",
forced_height = 10,
forced_width = 60,
shape = gears.shape.rounded_bar,
border_width = 2,
border_color = beautiful.border_color,
widget = wibox.widget.progressbar,
point = {
x = 0,
y = 10
}
})
s.batwidget = wibox.widget({
pbar,
forced_width = 40,
layout = wibox.layout.manual
})
s.batwidget_tooltip = awful.tooltip({
objects = {
s.batwidget
},
timer_function = util.bat_tooltip_fun,
font = "mono 14"
})
vicious.register(pbar, vicious.widgets.bat, "$2", 61, "BAT0")
s.mywibox = awful.wibar({
position = "top",
screen = s,
height = 30
})
local month_calendar = awful.widget.calendar_popup.month()
month_calendar:attach(mytextclock, "tr")
gears.timer.delayed_call(function()
local tag = require("awful.tag")
tag.viewnone()
screen[1].tags[5].selected = true
end)
local make_stats_widget
make_stats_widget = function()
local w = {
image = "/home/cji/priv/awesomescripts/analytics.png",
resize = true,
widget = wibox.widget.imagebox,
forced_width = 25
}
w = {
w,
left = 2,
top = 2,
bottom = 2,
right = 2,
widget = wibox.container.margin
}
w = {
w,
top = 5,
bottom = 3,
widget = wibox.container.margin
}
w = wibox.widget(w)
local wg = nil
local make_notification_widget
make_notification_widget = require("util").make_notification_widget
local clb_in
clb_in = function()
local txt = io.popen("du ~/Downloads/history/"):read("*a")
txt = txt .. ("\n" .. io.popen("df -h | grep /dev"):read("*a"))
wg = make_notification_widget(txt, {
x = 1291,
y = 41,
width = 530,
height = 200
}, ({
opacity = 1
}), {
font = "monospace 12",
align = "left",
valign = "top"
})
end
local clb_out
clb_out = function()
if wg then
wg.visible = false
wg = nil
end
end
w:connect_signal("mouse::enter", clb_in)
w:connect_signal("mouse::leave", clb_out)
return w
end
local ok, brightnessWidget = pcall(function()
PackageManager:load("brightness", true)
local brightness = PackageManager:findByName("brightness")
brightness:start()
return brightness:get_widget()
end)
if not ok then
print(brightnessWidget)
brightnessWidget = nil
end
return s.mywibox:setup({
layout = wibox.layout.align.horizontal,
{
layout = wibox.layout.fixed.horizontal,
s.mylayoutbox,
mylauncher,
s.mytaglist,
s.mypromptbox
},
s.mytasklist,
{
layout = wibox.layout.fixed.horizontal,
spacing = 15,
spacing_widget = {
make_sep(),
valign = "center",
halign = "center",
widget = wibox.container.place
},
wibox.widget({
forced_width = 20
}),
wibox.widget({
s.cpuwidget,
wibox.widget({
forced_width = 30
}),
make_mem_widget(),
layout = wibox.layout.align.horizontal,
forced_width = 215
}),
make_therm_widget(),
make_stats_widget(),
s.batwidget,
net_widgets.wireless({
interface = os.getenv("WIRELESS_CARD") or "wlp5s0",--"wlp0s20f3", -- ,
onclick = util.run_nmtui
}),
brightnessWidget,
require("volume")(),
wibox.widget({
wibox.widget({
forced_width = 30
}),
mytextclock,
wibox.widget({
forced_width = 30
}),
layout = wibox.layout.fixed.horizontal
}),
wibox.widget({
wibox.widget.systray(),
wibox.widget({
forced_width = 12
}),
layout = wibox.layout.fixed.horizontal
})
}
})
end)
end
return {
make_layoutbox = make_layoutbox,
make_tasklist = make_tasklist,
make_cpu_widget = make_cpu_widget,
get_top = get_top,
make_sep = make_sep,
initialize = initialize,
set_wallpaper = set_wallpaper
}