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
|
local awful = require("awful")
local wibox = require("wibox")
local layout = require("awful.layout")
local beautiful = require("beautiful")
local naughty = require("naughty")
local screen_widgets = {} -- need one widget per screen
local layout_icons = {
cornernw = "TT=",
cornerne = "=TT",
cornersw = "LL=",
cornerse = "=LL",
fairh = "#_#",
fairv = "##H",
floating = "><>",
magnifier = "=O=",
fullscreen = "[*]",
spiral = "[]@",
dwindle = "[]\\",
tile = "[]=",
tiletop = "LLL",
tilebottom = "TTT",
tileleft = "=[]",
max = function(s)
return string.format("[%s]", #s.clients > 0 and #s.clients or 'M')
end,
}
function update(screen_index)
local s = screen[screen_index or 1]
local w = screen_widgets[s]
local l = layout.get(s)
-- create widget if not existing
if w == nil then
screen_widgets[s] = {
widget = wibox.widget {
font = beautiful.layoutbox_font or beautiful.font_mono or "monospace 10",
widget = wibox.widget.textbox,
},
layout = l,
tooltip = awful.tooltip { delay_show = 1 },
}
w = screen_widgets[s]
w.tooltip:add_to_object(w.widget)
end
w.layout = l
-- set widget
local name = layout.getname(l)
w.tooltip:set_text(name)
local wtxt = layout_icons[name]
if type(wtxt) == 'function' then
wtxt = wtxt(s)
elseif wtxt == nil then
wtxt = "???"
end
w.widget:set_text(wtxt)
return w.widget
end
function update_screens()
for s, w in pairs(boxes) do
if s.valid then
update(s)
end
end
end
function update_tag(t)
update(t.screen)
end
function update_client(c)
update(c.screen)
end
tag.connect_signal("property::selected", update_tag)
tag.connect_signal("property::layout", update_tag)
tag.connect_signal("tagged", update_client) -- max
tag.connect_signal("untagged", update_client) -- max
tag.connect_signal("property::screen", update_screens)
return update
|