From 179e4025046f0b82d18c30e91a374093d0f25ddb Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 29 Dec 2024 17:22:55 -0500 Subject: [PATCH] refactor(ags): prioritise getters when using astal libs --- modules/ags/config/lib/hypr.ts | 34 +++++++------- modules/ags/config/lib/notify.ts | 2 +- .../config/widgets/applauncher/app-item.tsx | 6 +-- .../ags/config/widgets/applauncher/index.tsx | 10 ++--- .../ags/config/widgets/applauncher/launch.ts | 3 +- modules/ags/config/widgets/audio/profiles.tsx | 16 ++++--- modules/ags/config/widgets/audio/streams.tsx | 12 ++--- .../ags/config/widgets/bar/items/audio.tsx | 4 +- .../config/widgets/bar/items/bluetooth.tsx | 6 ++- .../ags/config/widgets/bar/items/clock.tsx | 6 +-- .../widgets/bar/items/current-client.tsx | 8 ++-- .../config/widgets/bar/items/current-icon.tsx | 4 +- .../ags/config/widgets/bar/items/network.tsx | 4 +- .../config/widgets/bar/items/notif-button.tsx | 8 ++-- modules/ags/config/widgets/bar/items/tray.tsx | 4 +- .../config/widgets/bar/items/workspaces.tsx | 28 ++++++------ .../ags/config/widgets/bluetooth/device.tsx | 6 +-- modules/ags/config/widgets/bluetooth/main.tsx | 34 +++++++------- modules/ags/config/widgets/greeter/index.tsx | 6 +-- .../ags/config/widgets/lockscreen/index.tsx | 22 +++++----- .../ags/config/widgets/misc/popup-window.tsx | 2 +- .../ags/config/widgets/misc/sorted-list.tsx | 9 ++-- .../config/widgets/network/access-point.tsx | 2 +- modules/ags/config/widgets/notifs/center.tsx | 2 +- modules/ags/config/widgets/notifs/gesture.tsx | 18 ++++---- .../config/widgets/notifs/notification.tsx | 14 +++--- .../widgets/on-screen-display/index.tsx | 4 +- .../widgets/on-screen-keyboard/gesture.ts | 44 +++++++++---------- .../widgets/on-screen-keyboard/keys.tsx | 12 ++--- .../ags/config/widgets/screenshot/index.tsx | 10 ++--- 30 files changed, 176 insertions(+), 164 deletions(-) diff --git a/modules/ags/config/lib/hypr.ts b/modules/ags/config/lib/hypr.ts index b30ace75..ad032722 100644 --- a/modules/ags/config/lib/hypr.ts +++ b/modules/ags/config/lib/hypr.ts @@ -6,21 +6,23 @@ import AstalHyprland from 'gi://AstalHyprland'; export const get_hyprland_monitor = (monitor: Gdk.Monitor): AstalHyprland.Monitor | undefined => { const hyprland = AstalHyprland.get_default(); - const manufacturer = monitor.manufacturer?.replace(',', ''); - const model = monitor.model?.replace(',', ''); + const manufacturer = monitor.get_manufacturer()?.replace(',', ''); + const model = monitor.get_model()?.replace(',', ''); const start = `${manufacturer} ${model}`; - return hyprland.get_monitors().find((m) => m.description?.startsWith(start)); + return hyprland.get_monitors().find((m) => m.get_description()?.startsWith(start)); }; export const get_hyprland_monitor_desc = (monitor: Gdk.Monitor): string => { const hyprland = AstalHyprland.get_default(); - const manufacturer = monitor.manufacturer?.replace(',', ''); - const model = monitor.model?.replace(',', ''); + const manufacturer = monitor.get_manufacturer()?.replace(',', ''); + const model = monitor.get_model()?.replace(',', ''); const start = `${manufacturer} ${model}`; - return `desc:${hyprland.get_monitors().find((m) => m.description?.startsWith(start))?.description}`; + return `desc:${hyprland + .get_monitors() + .find((m) => m.get_description()?.startsWith(start))?.get_description()}`; }; export const get_gdkmonitor_from_desc = (desc: string): Gdk.Monitor => { @@ -38,7 +40,7 @@ export const get_gdkmonitor_from_desc = (desc: string): Gdk.Monitor => { }; export const get_monitor_desc = (mon: AstalHyprland.Monitor): string => { - return `desc:${mon.description}`; + return `desc:${mon.get_description()}`; }; export const hyprMessage = (message: string) => new Promise(( @@ -66,25 +68,25 @@ export const centerCursor = (): void => { let y: number; const monitor = hyprland.get_focused_monitor(); - switch (monitor.transform) { + switch (monitor.get_transform()) { case 1: - x = monitor.x - (monitor.height / 2); - y = monitor.y - (monitor.width / 2); + x = monitor.get_x() - (monitor.get_height() / 2); + y = monitor.get_y() - (monitor.get_width() / 2); break; case 2: - x = monitor.x - (monitor.width / 2); - y = monitor.y - (monitor.height / 2); + x = monitor.get_x() - (monitor.get_width() / 2); + y = monitor.get_y() - (monitor.get_height() / 2); break; case 3: - x = monitor.x + (monitor.height / 2); - y = monitor.y + (monitor.width / 2); + x = monitor.get_x() + (monitor.get_height() / 2); + y = monitor.get_y() + (monitor.get_width() / 2); break; default: - x = monitor.x + (monitor.width / 2); - y = monitor.y + (monitor.height / 2); + x = monitor.get_x() + (monitor.get_width() / 2); + y = monitor.get_y() + (monitor.get_height() / 2); break; } diff --git a/modules/ags/config/lib/notify.ts b/modules/ags/config/lib/notify.ts index 3684be3c..3c29275b 100644 --- a/modules/ags/config/lib/notify.ts +++ b/modules/ags/config/lib/notify.ts @@ -18,7 +18,7 @@ interface NotifySendProps { urgency?: 'low' | 'normal' | 'critical' } -const escapeShellArg = (arg: string): string => `'${arg?.replace(/'/g, '\'\\\'\'')}'`; +const escapeShellArg = (arg: string | undefined): string => `'${arg?.replace(/'/g, '\'\\\'\'') ?? ''}'`; export const notifySend = ({ actions = [], diff --git a/modules/ags/config/widgets/applauncher/app-item.tsx b/modules/ags/config/widgets/applauncher/app-item.tsx index 419df209..e7ff2291 100644 --- a/modules/ags/config/widgets/applauncher/app-item.tsx +++ b/modules/ags/config/widgets/applauncher/app-item.tsx @@ -27,7 +27,7 @@ export class AppItem extends Widget.Box { const icon = ( ); @@ -36,7 +36,7 @@ export class AppItem extends Widget.Box {