-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse-config.lua
152 lines (141 loc) · 5.29 KB
/
parse-config.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
local wezterm = require "wezterm"
local util = require "util.util"
config_parser = {}
local datadir = util.path_join({wezterm.config_dir, "data"})
if not util.is_dir(datadir) then
os.execute("mkdir -p " .. datadir)
end
--[=====[
Some things like weather and stock quotes will have an "interval" filed. This
allows you to check things on a periodic basis and avoid getting rate-limited
when using APIs.
The format of the interval filed is <number><unit>, e.g., 15m for 15 minutes.
Valid units are (s)econd, (m)inute, (h)our, and (d)ay. An invalid entry will
result in the default of 15m. In other words, if you change an interval to
"10z", the function to determine the number and multiplier will not be able to
recognize the input and will default to 15 minutes.
--]=====]
function get_config()
local config = {
display = {
tab_bar_font = {
family = "Roboto",
size = 12,
stretch = "Normal",
weight = "Bold",
},
terminal_font = {
family = "JetBrains Mono",
size = 14,
stretch = "Normal",
weight = "Regular",
},
initial_cols = 80,
initial_rows = 25,
color_scheme = {
enable_gradient = false,
randomize_color_scheme = false,
scheme_name = "Novel"
},
window_background_opacity = 1,
window_padding = {
left = 10,
right = 20,
top = 0,
bottom = 0
}
},
status_bar = {
update_interval = 2,
system_status = {
disk_list = {{mount_point = "/", unit = "Gi"}},
enabled = true,
memory_unit = "Gi",
network_interface_list = {},
toggles = {
show_cpu_usage = true,
show_disk_usage = true,
show_load_averages = false,
show_memory_usage = true,
show_network_throughput = true,
show_uptime = true,
},
},
stock_quotes = {
data_file = util.path_join({datadir, "stock-quotes.json"}),
enabled = true,
indexes = {
show_djia = false,
show_nasdaq = false,
show_sp500 = false,
show_gold = false,
show_crude = false,
},
interval = "15m", -- decreasing too aggressively might get you rate-limited
symbols = {
"GOOG",
"AAPL"
}
},
toggles = {
show_battery = false,
show_branch_info = true,
show_clock = false,
show_hostname = false,
},
weather = {
api_key = nil, -- https://weatherapi.com/
conditions_file = util.path_join({datadir, "weather_conditions.json"}),
data_file = util.path_join({datadir, "weather.json"}),
enabled = false,
interval = "15m", -- decreasing too aggressively might get you rate-limited
locations = {"San Diego, CA, US"},
use_celsius = true,
},
wifi_status = {
data_file = util.path_join({datadir, "wifi-status.json"}),
enabled = true,
interval = "10s",
}
},
tabs = {
title_is_cwd = true,
},
}
-- set some OS-specific defaults
if (wezterm.target_triple == "x86_64-apple-darwin") or (wezterm.target_triple == "aarch64-apple-darwin") then
config["keymod"] = "SUPER"
config["os_name"] = "darwin"
elseif (wezterm.target_triple == "x86_64-unknown-linux-gnu") or (wezterm.target_triple == "aarch64-unknown-linux-gnu") then
config["keymod"] = "SHIFT|CTRL"
config["os_name"] = "linux"
end
-- find the Linux distro
if config["os_name"] == "linux" then
if util.file_exists("/etc/os-release") then
local file = io.open("/etc/os-release", "r")
if file then
for line in file:lines() do
if string.match(line, "^ID=") then
os_distro = line:match('ID="(.-)"$') or line:match('ID=(.-)$')
if os_distro then
config["os_distro"] = os_distro
end
elseif string.match(line, "^VERSION_ID=") then
os_version = line:match('VERSION_ID="(.-)"$') or line:match('VERSION_ID=(.-)$')
if os_version then
config["os_version"] = os_version
end
end
end
end
end
end
if util.file_exists( util.path_join({wezterm.config_dir, "overrides.lua"})) then
overrides = require "overrides"
config = overrides.override_config(config)
end
return config
end
config_parser.get_config = get_config
return config_parser