-
Notifications
You must be signed in to change notification settings - Fork 2
/
bar.lua
executable file
·101 lines (93 loc) · 2.75 KB
/
bar.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
#!/usr/bin/lua
local lemonbar = "lemonbar -d -p -o 3"
local height = 50
local outer_gap = 10
os.execute("bspc config window_gap " .. outer_gap
.. " && bspc config top_padding " .. height + outer_gap * 2)
local font_names = "Comic Mono Nerd Font,lxgw Wen Kai Mono"
local font_size = 10
local layout = require("layout")
local x = outer_gap
local width
local function fonts(names)
local output = ""
for font in names:gmatch("([^,]+)") do
output = output .. " -f \"" .. font .. "\"-" .. font_size
end
return output
end
local function actions(widget)
if widget.action == nil then
return ""
end
local output = ""
if widget.action.lclick ~= nil then
output = output .. "%{A:" .. widget.action.lclick .. ":}"
I = I + 1
end
if widget.action.mclick ~= nil then
output = output .. "%{A2:" .. widget.action.mclick .. ":}"
I = I + 1
end
if widget.action.rclick ~= nil then
output = output .. "%{A3:" .. widget.action.rclick .. ":}"
I = I + 1
end
if widget.action.scrollup ~= nil then
output = output .. "%{A4:" .. widget.action.scrollup .. ":}"
I = I + 1
end
if widget.action.scrolldown ~= nil then
output = output .. "%{A5:" .. widget.action.scrolldown .. ":}"
I = I + 1
end
return output
end
for _, widget in ipairs(layout.left) do
I = 0
width = (2 * widget.inner_gap + widget.len) * (font_size * 1.5)
if widget.command == "lua ./workspace.lua" then
os.execute("echo " .. x + widget.inner_gap * font_size * 1.5 / 2 .. " > ~/scripts/lemonbar/.x")
os.execute("echo " .. width - widget.inner_gap * font_size * 1.5 .. " > ~/scripts/lemonbar/.width")
end
os.execute("while true; do echo \""
.. actions(widget)
.. string.rep(' ', widget.inner_gap) .. "$("
.. widget.command
.. ") " .. ("%{A}"):rep(I) .. "\" ; sleep "
.. widget.interval .. "; done | "
.. lemonbar
.. fonts(font_names)
.. " -F \"#"
.. widget.color.foreground
.. "\" -B \"#"
.. widget.color.background
.. "\" -g " .. ("%d"):format(width)
.. "x" .. height
.. "+" .. ("%d"):format(x)
.. "+" .. outer_gap .. " &")
x = x + width + outer_gap
end
x = 2240 - outer_gap
for _, widget in ipairs(layout.right) do
I = 0
width = (2 * widget.inner_gap + widget.len) * (font_size * 1.5)
x = x - width
os.execute("while true; do echo \""
.. actions(widget)
.. string.rep(' ', widget.inner_gap) .. "$("
.. widget.command
.. ") " .. ("%{A}"):rep(I) .. "\" ; sleep "
.. widget.interval .. "; done | "
.. lemonbar
.. fonts(font_names)
.. " -F \"#"
.. widget.color.foreground
.. "\" -B \"#"
.. widget.color.background
.. "\" -g " .. ("%d"):format(width)
.. "x" .. height
.. "+" .. ("%d"):format(x)
.. "+" .. outer_gap .. " &")
x = x - outer_gap
end