From b47a0724aef3d12a65249c6d0580edc4fc75d530 Mon Sep 17 00:00:00 2001 From: rocketcamel Date: Tue, 16 Sep 2025 17:54:00 -0700 Subject: [PATCH] fix(status-bar): poll for new monitors --- astal/app.ts | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/astal/app.ts b/astal/app.ts index b7daa24..20076c2 100644 --- a/astal/app.ts +++ b/astal/app.ts @@ -1,11 +1,29 @@ -import { App } from "astal/gtk3"; +import { App, Gdk } from "astal/gtk3"; import style from "./style.scss"; import Bar from "./widget/Bar"; +import { GLib } from "astal"; App.start({ css: style, icons: "icons", - main() { - App.get_monitors().map(Bar); - }, + main() {}, +}); + +let knownMonitors = new Set(); + +function checkMonitors() { + const currentMonitors = App.get_monitors(); + currentMonitors.forEach((monitor) => { + if (!knownMonitors.has(monitor.model)) { + knownMonitors.add(monitor.model); + Bar(monitor); + } + }); +} + +checkMonitors(); + +GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 10, () => { + checkMonitors(); + return true; });