-
Notifications
You must be signed in to change notification settings - Fork 0
/
textlayout-widget.lua
51 lines (39 loc) · 1.24 KB
/
textlayout-widget.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
local awful = require("awful")
local wibox = require("wibox")
local text_layout = {}
function text_layout:new(args)
args = args or {}
self.CUSTOM_LAYOUTS = {
tile = args.tile or "[]=",
fairv = args.fairv or "==",
max = args.max or "[M]",
floating = args.floating or "><>",
dwindle = args.dwindle or "[\\\\]",
spiral = args.spiral or "[@]",
}
self.layout_textbox = wibox.widget{
widget = wibox.widget.textbox
}
self.args = args
tag.connect_signal("property::layout", function()
text_layout:set_layout_text()
end)
tag.connect_signal("property::selected", function ()
text_layout:set_layout_text()
end)
self:set_layout_text()
return self.layout_textbox
end
function text_layout:set_layout_text()
local name = awful.layout.getname(awful.layout.get(awful.screen.focused()))
if self.CUSTOM_LAYOUTS[name] ~= nil then
self.layout_textbox:set_text(self.CUSTOM_LAYOUTS[name])
elseif self.args[name] ~= nil then
self.layout_textbox:set_text(self.args[name])
else
self.layout_textbox:set_text(name)
end
end
return setmetatable(text_layout, {
__call = text_layout.new,
})