diff options
author | Aylur <[email protected]> | 2024-05-26 19:54:00 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-05-26 19:54:00 +0200 |
commit | ae2b733af5d4693534bec237e38c0a57716f4c37 (patch) | |
tree | b3d33e5b6f86173e6150a9c52a2565eab80a87a4 /gjs | |
parent | 9d83811e3f3158a356ece00971db4765205732a9 (diff) |
rename vfunc_response to vfunc_request
Diffstat (limited to 'gjs')
-rwxr-xr-x | gjs/sample.js | 43 | ||||
-rw-r--r-- | gjs/src/application.ts | 4 |
2 files changed, 2 insertions, 45 deletions
diff --git a/gjs/sample.js b/gjs/sample.js deleted file mode 100755 index 2aa6145..0000000 --- a/gjs/sample.js +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env -S gjs -m -import { Variable, App, Widget, Astal, bind } from "./dist/index.js" -import Playerctl from "gi://Playerctl" - -// state -const player = Playerctl.Player.new("spotify") -const date = Variable("").poll(1000, "date") -const title = Variable(player.get_title()).observe(player, "metadata", () => player.get_title()) - -// ui -function Bar(monitor) { - return Widget.Window( - { - monitor, - application: App, - exclusivity: Astal.Exclusivity.EXCLUSIVE, - anchor: Astal.WindowAnchor.BOTTOM | - Astal.WindowAnchor.LEFT | - Astal.WindowAnchor.RIGHT, - }, - Widget.CenterBox({ - startWidget: Widget.Label({ - label: date(l => `Current date: ${l}`), - }), - endWidget: Widget.Label({ - label: bind(title).as(t => `Title: ${t}`), - }), - }), - ) -} - -// main -App.start({ - requestHandler(msg, res) { - switch (msg) { - case "inspector": return res(App.inspector()) - case "quit": return res(App.quit()) - default: return App.eval(msg).then(res).catch(console.error) - } - }, -}, () => { - Bar(0) -}) diff --git a/gjs/src/application.ts b/gjs/src/application.ts index b98b831..b34e798 100644 --- a/gjs/src/application.ts +++ b/gjs/src/application.ts @@ -39,10 +39,10 @@ class AstalJS extends Astal.Application { requestHandler?: RequestHandler - vfunc_response(msg: string, conn: Gio.SocketConnection): void { + vfunc_request(msg: string, conn: Gio.SocketConnection): void { if (typeof this.requestHandler === "function") { this.requestHandler(msg, response => { - Astal.write_sock(conn, response, (_, res) => + Astal.write_sock(conn, String(response), (_, res) => Astal.write_sock_finish(res), ) }) |