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
|
import { GLib, monitorFile, readFileAsync, Variable } from "astal";
import { Astal } from "astal/gtk3";
import { loadStyleAsync } from "./app";
const CONFIG = `${GLib.get_user_config_dir()}/caelestia/shell.json`;
const s = <T>(v: T): Variable<T> => Variable(v);
const warn = (e: Error) => console.warn(`Invalid config: ${e}`);
const updateSection = (from: { [k: string]: any }, to: { [k: string]: any }, path: string) => {
for (const [k, v] of Object.entries(from)) {
if (to.hasOwnProperty(k)) {
if (typeof v === "object" && v !== null && !Array.isArray(v)) updateSection(v, to[k], `${path}.${k}`);
else if (typeof v === typeof to[k].get()) to[k].set(v);
else console.warn(`Invalid type for ${path}.${k}: ${typeof v} != ${typeof to[k].get()}`);
} else console.warn(`Unknown config key: ${path}.${k}`);
}
};
export const updateConfig = async () => {
const conf: { [k: string]: any } = JSON.parse(await readFileAsync(CONFIG));
for (const [k, v] of Object.entries(conf)) {
if (config.hasOwnProperty(k)) updateSection(v, config[k as keyof typeof config], k);
else console.warn(`Unknown config key: ${k}`);
}
loadStyleAsync().catch(console.error);
};
export const initConfig = () => {
monitorFile(CONFIG, () => updateConfig().catch(warn));
updateConfig().catch(warn);
};
const config = {
// Modules
bar: {
vertical: s(true),
modules: {
osIcon: {
enabled: s(true),
},
activeWindow: {
enabled: s(true),
},
mediaPlaying: {
enabled: s(true),
},
workspaces: {
enabled: s(true),
shown: s(5),
},
tray: {
enabled: s(true),
},
statusIcons: {
enabled: s(true),
},
pkgUpdates: {
enabled: s(true),
},
notifCount: {
enabled: s(true),
},
battery: {
enabled: s(true),
},
dateTime: {
enabled: s(true),
format: s("%d/%m/%y %R"),
detailedFormat: s("%c"),
},
power: {
enabled: s(true),
},
},
},
launcher: {
maxResults: s(15), // Max shown results at one time (i.e. max height of the launcher)
apps: {
maxResults: s(30), // Actual max results, -1 for infinite
pins: s([
["zen", "firefox", "waterfox", "google-chrome", "chromium", "brave-browser"],
["foot", "alacritty", "kitty", "wezterm"],
["thunar", "nemo", "nautilus"],
["codium", "code", "clion", "intellij-idea-ultimate-edition"],
["spotify-adblock", "spotify", "audacious", "elisa"],
]),
},
files: {
maxResults: s(40), // Actual max results, -1 for infinite
fdOpts: s(["-a", "-t", "f"]), // Options to pass to `fd`
},
math: {
maxResults: s(40), // Actual max results, -1 for infinite
},
windows: {
maxResults: s(-1), // Actual max results, -1 for infinite
weights: {
// Weights for fuzzy sort
title: s(1),
class: s(1),
initialTitle: s(0.5),
initialClass: s(0.5),
},
},
todo: {
notify: s(true),
},
},
notifpopups: {
maxPopups: s(-1),
expire: s(false),
agoTime: s(true), // Whether to show time in ago format, e.g. 10 mins ago, or raw time, e.g. 10:42
},
osds: {
volume: {
position: s(Astal.WindowAnchor.RIGHT),
margin: s(20),
hideDelay: s(1500),
showValue: s(true),
},
brightness: {
position: s(Astal.WindowAnchor.LEFT),
margin: s(20),
hideDelay: s(1500),
showValue: s(true),
},
lock: {
spacing: s(5),
caps: {
hideDelay: s(1000),
},
num: {
hideDelay: s(1000),
},
},
},
// Services
math: {
maxHistory: 100,
},
updates: {
interval: 900000,
},
weather: {
interval: 600000,
key: "assets/weather-api-key.txt", // Path to file containing api key relative to the base directory. To get a key, visit https://weatherapi.com/
location: "", // Location as a string or empty to autodetect
imperial: false,
},
cpu: {
interval: 2000,
},
gpu: {
interval: 2000,
},
memory: {
interval: 5000,
},
storage: {
interval: 5000,
},
};
export const { bar, launcher, notifpopups, osds, math, updates, weather, cpu, gpu, memory, storage } = config;
|