From 02fd2e97f2c8a53bf2344e6fa8b14769cb15ee38 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:35:37 +1100 Subject: refactor: move ts to src Also move popupwindow to own file --- app.tsx | 12 +- modules/bar.tsx | 500 ------------------------------------------ modules/launcher.tsx | 390 -------------------------------- modules/notifpopups.tsx | 177 --------------- modules/osds.tsx | 326 --------------------------- scss/notifpopups.scss | 2 +- services/apps.ts | 3 - services/math.ts | 151 ------------- services/monitors.ts | 127 ----------- services/players.ts | 154 ------------- services/updates.ts | 148 ------------- src/modules/bar.tsx | 500 ++++++++++++++++++++++++++++++++++++++++++ src/modules/launcher.tsx | 391 +++++++++++++++++++++++++++++++++ src/modules/notifications.tsx | 57 +++++ src/modules/notifpopups.tsx | 49 +++++ src/modules/osds.tsx | 326 +++++++++++++++++++++++++++ src/services/apps.ts | 3 + src/services/math.ts | 151 +++++++++++++ src/services/monitors.ts | 127 +++++++++++ src/services/players.ts | 154 +++++++++++++ src/services/updates.ts | 148 +++++++++++++ src/utils/icons.ts | 86 ++++++++ src/utils/mpris.ts | 16 ++ src/utils/strings.ts | 1 + src/utils/system.ts | 21 ++ src/utils/widgets.ts | 45 ++++ src/widgets/notification.tsx | 132 +++++++++++ src/widgets/popupwindow.ts | 39 ++++ utils/icons.ts | 86 -------- utils/mpris.ts | 16 -- utils/strings.ts | 1 - utils/system.ts | 21 -- utils/widgets.tsx | 84 ------- 33 files changed, 2253 insertions(+), 2191 deletions(-) delete mode 100644 modules/bar.tsx delete mode 100644 modules/launcher.tsx delete mode 100644 modules/notifpopups.tsx delete mode 100644 modules/osds.tsx delete mode 100644 services/apps.ts delete mode 100644 services/math.ts delete mode 100644 services/monitors.ts delete mode 100644 services/players.ts delete mode 100644 services/updates.ts create mode 100644 src/modules/bar.tsx create mode 100644 src/modules/launcher.tsx create mode 100644 src/modules/notifications.tsx create mode 100644 src/modules/notifpopups.tsx create mode 100644 src/modules/osds.tsx create mode 100644 src/services/apps.ts create mode 100644 src/services/math.ts create mode 100644 src/services/monitors.ts create mode 100644 src/services/players.ts create mode 100644 src/services/updates.ts create mode 100644 src/utils/icons.ts create mode 100644 src/utils/mpris.ts create mode 100644 src/utils/strings.ts create mode 100644 src/utils/system.ts create mode 100644 src/utils/widgets.ts create mode 100644 src/widgets/notification.tsx create mode 100644 src/widgets/popupwindow.ts delete mode 100644 utils/icons.ts delete mode 100644 utils/mpris.ts delete mode 100644 utils/strings.ts delete mode 100644 utils/system.ts delete mode 100644 utils/widgets.tsx diff --git a/app.tsx b/app.tsx index be3231c..31e7ed1 100644 --- a/app.tsx +++ b/app.tsx @@ -1,11 +1,11 @@ import { execAsync, GLib, writeFileAsync } from "astal"; import { App } from "astal/gtk3"; -import Bar from "./modules/bar"; -import Launcher from "./modules/launcher"; -import NotifPopups from "./modules/notifpopups"; -import Osds from "./modules/osds"; -import Monitors from "./services/monitors"; -import Players from "./services/players"; +import Bar from "./src/modules/bar"; +import Launcher from "./src/modules/launcher"; +import NotifPopups from "./src/modules/notifpopups"; +import Osds from "./src/modules/osds"; +import Monitors from "./src/services/monitors"; +import Players from "./src/services/players"; const loadStyleAsync = async () => { if (!GLib.file_test(`${SRC}/scss/scheme/_index.scss`, GLib.FileTest.EXISTS)) diff --git a/modules/bar.tsx b/modules/bar.tsx deleted file mode 100644 index 5ed309e..0000000 --- a/modules/bar.tsx +++ /dev/null @@ -1,500 +0,0 @@ -import { execAsync, GLib, register, Variable } from "astal"; -import { bind, kebabify } from "astal/binding"; -import { App, Astal, astalify, Gdk, Gtk, type ConstructProps } from "astal/gtk3"; -import AstalBluetooth from "gi://AstalBluetooth"; -import AstalHyprland from "gi://AstalHyprland"; -import AstalNetwork from "gi://AstalNetwork"; -import AstalNotifd from "gi://AstalNotifd"; -import AstalTray from "gi://AstalTray"; -import AstalWp01 from "gi://AstalWp"; -import { bar as config } from "../config"; -import type { Monitor } from "../services/monitors"; -import Players from "../services/players"; -import Updates from "../services/updates"; -import { getAppCategoryIcon } from "../utils/icons"; -import { ellipsize } from "../utils/strings"; -import { osIcon } from "../utils/system"; -import { setupCustomTooltip } from "../utils/widgets"; - -const hyprland = AstalHyprland.get_default(); - -const hookFocusedClientProp = ( - self: any, // Ugh why is there no base Widget type - prop: keyof AstalHyprland.Client, - callback: (c: AstalHyprland.Client | null) => void -) => { - let id: number | null = null; - let lastClient: AstalHyprland.Client | null = null; - self.hook(hyprland, "notify::focused-client", () => { - if (id) lastClient?.disconnect(id); - lastClient = hyprland.focusedClient; // Can be null - id = lastClient?.connect(`notify::${kebabify(prop)}`, () => callback(lastClient)); - callback(lastClient); - }); - self.connect("destroy", () => id && lastClient?.disconnect(id)); - callback(lastClient); -}; - -const OSIcon = () =>