-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
54 lines (50 loc) · 1.47 KB
/
Copy pathapp.ts
File metadata and controls
54 lines (50 loc) · 1.47 KB
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
import { App, Gdk, Gtk } from "astal/gtk3";
import style from "./app.scss";
import Bar from "./widget/bar/bar";
import OSD from "./widget/osd/osd";
import Applauncher from "widget/applauncher/applauncher";
// import NotificationPopups from "./widget/notifications/notification-popup";
import defaultApp from "./lib/default_app";
// entry point of the shell, where we determine
// - the stylesheet
// - the custom icon path
// - the main function
// - the request handler
App.start({
css: style,
icons: "./icons",
main: main,
requestHandler,
});
// main function where must be created the used widgets
function main() {
const windows: Array<(gdkmonitor: Gdk.Monitor) => Gtk.Widget> = [
Bar,
OSD,
Applauncher,
// NotificationPopups,
];
for (const window of windows) {
const windowMaps = new Map<Gdk.Monitor, Gtk.Widget>();
for (const gdkmonitor of App.get_monitors()) {
windowMaps.set(gdkmonitor, window(gdkmonitor));
}
App.connect("monitor-added", (_, gdkmonitor) =>
windowMaps.set(gdkmonitor, window(gdkmonitor))
);
App.connect("monitor-removed", (_, gdkmonitor) => {
windowMaps.get(gdkmonitor)?.destroy();
windowMaps.delete(gdkmonitor);
});
}
}
// request handler, with which we can send messages like
// ```bash
// astal defaultApp --instance astal
// ```
function requestHandler(request: string, res: (response: any) => void) {
if (request == "defaultApp") {
defaultApp();
}
res("unknown command");
}