diff --git a/ags/app.ts b/ags/app.ts index 221ce58..1e0c672 100644 --- a/ags/app.ts +++ b/ags/app.ts @@ -1,12 +1,13 @@ -import { Gio, monitorFile, readFile, Process } from "astal"; import { App } from "astal/gtk3" import { Bar } from "./window/Bar"; import { runStyleHandler } from "./scripts/style-handler"; +import "./scripts/reload-handler"; runStyleHandler(); App.start({ + instanceName: "astal", main() { Bar(0); } diff --git a/ags/scripts/reload-handler.ts b/ags/scripts/reload-handler.ts new file mode 100644 index 0000000..ec1e4a7 --- /dev/null +++ b/ags/scripts/reload-handler.ts @@ -0,0 +1,17 @@ +import { Gio, monitorFile, Process } from "astal"; + +const monitoringPaths = [ "./scripts", "./widget", "./app.ts", "env.d.ts" ]; + +function restartInstance(instanceName?: string) { + Process.exec_async(`ags run`, () => {}); + Process.exec_async(`astal -q ${ instanceName ? instanceName : "astal" }`, () => {}); +} + +monitoringPaths.map((path: string) => { + monitorFile( + path, + () => { + restartInstance("astal"); + } + ) +})