summaryrefslogtreecommitdiff
path: root/gjs
diff options
context:
space:
mode:
Diffstat (limited to 'gjs')
-rw-r--r--gjs/src/application.ts17
1 files changed, 11 insertions, 6 deletions
diff --git a/gjs/src/application.ts b/gjs/src/application.ts
index b42492f..1141ad7 100644
--- a/gjs/src/application.ts
+++ b/gjs/src/application.ts
@@ -11,6 +11,8 @@ type Config = Partial<{
cursorTheme: string
css: string
requestHandler: RequestHandler
+ main(...args: string[]): void
+ client(message: (msg: string) => string, ...args: string[]): void
hold: boolean
}>
@@ -51,16 +53,19 @@ class AstalJS extends Astal.Application {
}
}
- start({ requestHandler, css, hold, ...cfg }: Config = {}, callback?: (args: string[]) => void) {
+ start({ requestHandler, css, hold, main, client, ...cfg }: Config = {}) {
+ client ??= () => {
+ print(`Astal instance "${this.instanceName}" already running`)
+ exit(1)
+ }
+
Object.assign(this, cfg)
setConsoleLogDomain(this.instanceName)
this.requestHandler = requestHandler
- this.connect("activate", () => callback?.(programArgs))
- if (!this.acquire_socket()) {
- print(`Astal instance "${this.instanceName}" already running`)
- exit(1)
- }
+ this.connect("activate", () => main?.(...programArgs))
+ if (!this.acquire_socket())
+ client(msg => this.message(msg)!, ...programArgs)
if (css)
this.apply_css(css, false)