blob: 86d98e6131a35a539a7a48413e9b33853de3c799 (
plain)
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
|
import { execAsync, GLib, writeFileAsync } from "astal";
import { App } from "astal/gtk3";
import AstalHyprland from "gi://AstalHyprland";
import Bar from "./modules/bar";
import Launcher from "./modules/launcher";
import NotifPopups from "./modules/notifpopups";
import Players from "./services/players";
import { PopupWindow } from "./utils/widgets";
const loadStyleAsync = async () => {
if (!GLib.file_test(`${SRC}/scss/scheme/_index.scss`, GLib.FileTest.EXISTS))
await writeFileAsync(`${SRC}/scss/scheme/_index.scss`, '@forward "mocha";');
App.apply_css(await execAsync(`sass ${SRC}/style.scss`), true);
};
App.start({
instanceName: "caelestia",
icons: "assets/icons",
iconTheme: "Adwaita",
main() {
loadStyleAsync().catch(console.error);
<Launcher />;
<NotifPopups />;
AstalHyprland.get_default().monitors.forEach(m => <Bar monitor={m} />);
console.log("Caelestia started");
},
requestHandler(request, res) {
let log = true;
if (request === "reload css") loadStyleAsync().catch(console.error);
else if (request === "media play pause") Players.get_default().lastPlayer?.play_pause();
else if (request === "media next") Players.get_default().lastPlayer?.next();
else if (request === "media previous") Players.get_default().lastPlayer?.previous();
else if (request === "media stop") Players.get_default().lastPlayer?.stop();
else if (request.startsWith("toggle")) {
const window = App.get_window(request.slice(7));
if (window instanceof PopupWindow) window.toggle();
else App.toggle_window(request.slice(7));
log = false;
} else return res("Unknown command: " + request);
if (log) console.log(`Request handled: ${request}`);
res("OK");
},
});
|