From efb7e709c6ffe88b48d1bd673b231201a8427190 Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 14 Aug 2023 17:26:35 +0200 Subject: [PATCH 1/4] map monitors by id instead of name #41 --- src/service/hyprland.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service/hyprland.ts b/src/service/hyprland.ts index 5f250b9..e48e155 100644 --- a/src/service/hyprland.ts +++ b/src/service/hyprland.ts @@ -27,7 +27,7 @@ class HyprlandService extends Service { } _active: Active; - _monitors: Map; + _monitors: Map; _workspaces: Map; _clients: Map; @@ -68,7 +68,7 @@ class HyprlandService extends Service { const monitors = await execAsync('hyprctl -j monitors'); this._monitors = new Map(); (JSON.parse(monitors) as { [key: string]: any }[]).forEach(monitor => { - this._monitors.set(monitor.name, monitor); + this._monitors.set(monitor.id, monitor); if (monitor.focused) { this._active.monitor = monitor.name; this._active.workspace = monitor.activeWorkspace; From 4998d17d704d6407e3facc80b5e903a945b3e6a8 Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 14 Aug 2023 17:41:18 +0200 Subject: [PATCH 2/4] Utils.subprocess handle empty output (fix #42) --- src/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index ee53339..7a8214d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -273,12 +273,12 @@ export function subprocess( stdout.read_line_async(GLib.PRIORITY_LOW, null, (stdout, res) => { try { const output = stdout?.read_line_finish_utf8(res)[0]; - if (output) { + if (typeof output === 'string' && stdout) { callback(output); read(stdout); } } catch (e) { - return onError(e as Error); + onError(e as Error); } }); }; From 3a407df2796a1579726b4844de578fe1303e1500 Mon Sep 17 00:00:00 2001 From: Aylur Date: Thu, 17 Aug 2023 00:03:45 +0200 Subject: [PATCH 3/4] fix setStyle memory leak --- src/widget.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widget.ts b/src/widget.ts index ba3cf9b..f249628 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -50,11 +50,17 @@ const widgets: { [key: string]: (props: any) => Gtk.Widget } = { 'menuitem': Widgets.MenutItem, }; +const widgetProviders: Map = new Map(); export function setStyle(widget: Gtk.Widget, css: string) { + const previous = widgetProviders.get(widget); + if (previous) + widget.get_style_context().remove_provider(previous); + const provider = new Gtk.CssProvider(); const style = `* { ${css} }`; provider.load_from_data(style); widget.get_style_context().add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_USER); + widgetProviders.set(widget, provider); } export function toggleClassName(widget: Gtk.Widget, className: string, condition = true) { From 1efb673426903819187e37f341e9d718aec7a56a Mon Sep 17 00:00:00 2001 From: Aylur Date: Thu, 17 Aug 2023 00:05:34 +0200 Subject: [PATCH 4/4] fix hyprland urgent window #45 --- src/service/hyprland.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/hyprland.ts b/src/service/hyprland.ts index e48e155..f1a6248 100644 --- a/src/service/hyprland.ts +++ b/src/service/hyprland.ts @@ -20,7 +20,7 @@ interface Active { class HyprlandService extends Service { static { Service.register(this, { - 'urgent-window': ['int'], + 'urgent-window': ['string'], 'submap': ['string'], 'keyboard-layout': ['string', 'string'], });