-
Notifications
You must be signed in to change notification settings - Fork 31
/
conky.conf
184 lines (169 loc) · 6.59 KB
/
conky.conf
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
-- vim: ft=lua:ts=4:sw=4:et:ai:cin
-- !! WARNING !!
-- Do *NOT* modify this file for customization. Instead, create a `local.conf`
-- file from `local.conf.example` and make changes over there.
local _dir_ = debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])") or "./"
if not string.find(package.path, _dir_ .. "lib/?.lua;", 1, true) then
package.path = _dir_ .. "lib/?.lua;" .. _dir_ .. "lib/?/init.lua;" .. package.path
end
local utils = require("utils")
-- the global LCC object
-- NOTE: lcc must be global for other globally scoped functions to access it
-- (e.g. tform functions rely on `lcc.config.scale`)
_G.lcc = { root_dir = _dir_ }
-- ensure global conky object, if not already available (when loaded by main.lua)
_G.conky = _G.conky or {}
require("tform") -- global `T_` created and available
require("components") -- global `C_` created and available
lcc.config = {
scale = 1, -- scale the whole panel (>1 to enlarge, <1 to shrink)
spacing = 18, -- vertical spacing between components (in pixels *before* scaling)
width = 270, -- full-width of panel content (in pixels *before* scaling)
width_half = 130, -- half-width of panel, for bars and graphs (in pixels *before* scaling)
storage_include_fs = "", -- filesystem types to include (comma-separated string)
storage_exclude_fs = "", -- filesystem types to exclude (comma-separated string)
storage_exclude_paths = { -- mount paths to exclude (array or comma-separated string)
"^/boot/",
"^/var/snap/",
},
}
-- NOTE: when local_conf is ready, custom lcc.config.scale (if specified in
-- local.conf) is also effective. and transform functions will work properly
-- for global settings below.
local local_conf = { lcc = {}, conky = {} }
do
setmetatable(local_conf, { __index = _G }) -- global fallback
-- update global lcc.config with local values, this has to be done on the fly
-- in `local.conf` so that other settings (e.g. fonts) can use the correct
-- config values
-- NOTE: __newindex only gets called for an absent key, a second assignment
-- won't change the global value
setmetatable(local_conf.lcc, {
__newindex = function(t, k, v)
rawset(t, k, v)
if k ~= "config" then return end
if _G.lcc[k] == nil then _G.lcc[k] = {} end
utils.table.update(_G.lcc[k], v)
end
})
utils.load_in_env(_dir_ .. "local.conf", local_conf)
setmetatable(local_conf, nil)
end
-- font definitions
lcc.fonts = {
icon = T_ "LeanConkyConfig:normal:size=$sc{12}", -- icons
icon_s = T_ "LeanConkyConfig:normal:size=$sc{8.5}", -- icons (small)
h1 = T_ "sans-serif:bold:size=$sc{10}", -- heading 1
h2 = T_ "sans-serif:bold:size=$sc{8}", -- heading 2
date = T_ "sans-serif:normal:size=$sc{18}", -- date
week = T_ "sans-serif:bold:size=$sc{7}", -- week
year = T_ "sans-serif:normal:size=$sc{7}", -- year
time = T_ "LeanConkyConfig:normal:size=$sc{18}", -- time
time_alt = T_ "sans-serif:bold:size=$sc{18}" -- time (fallback)
}
-- Conky settings
conky.config = {
alignment = "top_right",
background = false,
border_inner_margin = T_.sr(8),
border_outer_margin = T_.sr(0),
border_width = T_.sr(1),
cpu_avg_samples = 2,
default_bar_height = T_.sr(4),
default_bar_width = 0,
default_color = "white",
default_graph_height = T_.sr(32),
default_graph_width = 0,
default_outline_color = "#555555",
default_shade_color = "#555555",
diskio_avg_samples = 2,
double_buffer = true,
draw_borders = false,
draw_graph_borders = true,
draw_outline = true,
draw_shades = false,
extra_newline = false,
font = T_ "sans-serif:normal:size=$sc{8}",
gap_x = T_.sr(0),
gap_y = T_.sr(0),
lua_load = _dir_ .. "main.lua",
maximum_width = T_.sr(lcc.config.width),
minimum_height = T_.sr(32),
minimum_width = T_.sr(lcc.config.width),
net_avg_samples = 2,
no_buffers = true,
out_to_console = false,
out_to_stderr = false,
override_utf8_locale = true,
own_window = true,
own_window_argb_value = 128,
own_window_argb_visual = true,
own_window_class = "conky",
own_window_hints = "undecorated,below,sticky,skip_taskbar,skip_pager",
own_window_title = "conky-lcc",
own_window_transparent = false,
own_window_type = "desktop",
show_graph_range = false,
show_graph_scale = false,
stippled_borders = T_.sr(0),
store_graph_data_explicitly = false,
top_cpu_separate = false,
update_interval = 2,
uppercase = false,
use_spacer = "none",
use_xft = true,
xinerama_head = 0,
-- COLORS --
color0 = "white", -- clock color
color1 = "white", -- heading 1 color
color2 = "white", -- heading 2 color
color3 = "lightgray", -- chart color
}
-- update global settings with custom values
utils.table.update(lcc.fonts, local_conf.lcc.fonts)
utils.table.update(conky.config, local_conf.conky.config)
-- NOTE: for backward compatibility, will be deprecated in a future release
utils.table.update(lcc.fonts, local_conf.local_fonts)
utils.table.update(conky.config, local_conf.local_config)
-- remove unavailable fonts
do
for k, _ in pairs(lcc.fonts) do
local font = lcc.fonts[k]
local p = font:find(":")
if p then
font = font:sub(1, p - 1)
end
font = utils.trim(font)
if #font > 0 and font ~= "sans-serif" and font ~= "serif" and font ~= "courier" and font ~= "monospace" then
local s = utils.sys_call('fc-list -f "%{family[0]}" "' .. font .. '"', true)
if #s < 1 then
lcc.fonts[k] = nil
end
elseif not p then
lcc.fonts[k] = nil
end
end
end
-- extra context variables to be used by templates or hooks
utils.table.update(lcc, {
half_bar_size = string.format("%d,%d", conky.config.default_bar_height, T_.sr(lcc.config.width_half)),
half_graph_size = string.format("%d,%d", conky.config.default_graph_height, T_.sr(lcc.config.width_half))
})
-- define panel with components
lcc.panel_presets = {
default = {
"datetime",
"system",
"cpu",
"memory",
"storage",
"network",
{ "vspace", -20 }, -- hack: remove excessive space
}
}
lcc.panel = lcc.panel_presets.default
-- NOTE: the panel is *replaced* in whole by the local one, while other settings
-- are just partially overridden
if local_conf.lcc.panel then lcc.panel = local_conf.lcc.panel end
-- build the panel
conky.text = C_.build_panel()