-
Notifications
You must be signed in to change notification settings - Fork 1
/
configs.lua
103 lines (89 loc) · 2.26 KB
/
configs.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
-------------------------------------------------------------
-- Carrot configuration library
-------------------------------------------------------------
-- Licensed under the GNU General Public License v3:
-- https://opensource.org/licenses/GPL-3.0
-------------------------------------------------------------
-- Copyright (c) 2018 Pouyan Heyratpour <[email protected]>
-------------------------------------------------------------
local Utils = require("carrot.utils")
local DEFAULT = {
theme = "default",
wallpaper = "",
mod = "Mod4",
alt = "Mod1",
tags = {"1", "2", "3", "4", "Mid", "6", "7", "8", "9"},
apps = {
terminal = "uxvt",
editor = os.getenv("EDITOR") or "vim",
geditor = "atom",
browser = "firefox",
explorer = "thunar",
locker = "slock",
shoter = "scrot",
},
wibars = {
top = {
position = "top",
widgets = {
"launcher",
"taglist",
"promptbox",
"tasklist",
"systray",
"keyboardlayout",
"textclock",
"layoutbox",
}
}
},
autostarts = {
-- title = {command = "", tags = {1, 4, 7}}
}
}
local function read(path)
local conf = {}
fp = io.open(path, "r")
if nil == fp then
return {}
end
for line in fp:lines() do
line = line:match("%s*(.+)")
-- Ignore commented lines
if line and line:sub(1, 1) ~= "#"
and line:sub(1, 1) ~= ";" then
local option = line:match("%S+"):lower()
local value = line:match("%S*%s*(.*)")
local last = option:match("%.?(%w+)$")
local item = conf
for nxt in option:gmatch("%s*(.-)%.") do
item[nxt] = item[nxt] or {}
item = item[nxt]
end
if not value then
value = true
else
if value:find(",") then
value = value .. ","
local arr = {}
for entry in value:gmatch("%s*(.-),") do
arr[#arr + 1] = entry
end
value = arr
end
end
item[last] = value
end
end
fp:close()
return conf
end
local function loadFile(path)
local d = DEFAULT
return Utils.Merge(d, read(path))
end
return {
DEFAULT = DEFAULT;
LoadFile = loadFile;
}
-- vim: foldmethod=marker:filetype=lua:expandtab:shiftwidth=2:tabstop=2:softtabstop=2:textwidth=80