diff options
author | Aylur <[email protected]> | 2024-07-18 00:38:33 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-07-18 00:38:33 +0200 |
commit | 97040efe066ec046c72e63658e1aba534ccf2e95 (patch) | |
tree | a5a30c71cb2f6c9d30baf9337bb3092f5819fede | |
parent | d048f204fd549b6a80f5994380b2f29049095028 (diff) |
auto apply bundled css
-rw-r--r-- | gjs/src/application.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gjs/src/application.ts b/gjs/src/application.ts index 4a184e1..6a75d46 100644 --- a/gjs/src/application.ts +++ b/gjs/src/application.ts @@ -1,4 +1,4 @@ -import { Astal, GObject, Gio } from "./imports.js" +import { Astal, GObject, Gio, GLib } from "./imports.js" type RequestHandler = { (request: string, res: (response: any) => void): void @@ -67,7 +67,18 @@ class AstalJS extends Astal.Application { setConsoleLogDomain(this.instanceName) this.requestHandler = requestHandler - this.connect("activate", () => main?.(...programArgs)) + this.connect("activate", () => { + // @ts-expect-error missing url type + const path: string[] = import.meta.url.split("/").slice(3) + const file = path.at(-1)!.replace(".js", ".css") + const css = `/${path.slice(0, -1).join("/")}/${file}` + print(path, css) + if (GLib.file_test(css, GLib.FileTest.EXISTS)) + this.apply_css(css, false) + + main?.(...programArgs) + }) + if (!this.acquire_socket()) return client(msg => this.message(msg)!, ...programArgs) |