From dddb4bce11a9f8123cf3c3ea20c812b04806155a Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Tue, 11 Mar 2025 17:43:29 +0700 Subject: [PATCH] refactor --- widget/Bar.tsx | 45 +++++----------------------- widget/modules/LauncherButton.tsx | 13 ++++++++ widget/modules/MediaPlayerButton.tsx | 27 +++++++++++++++++ widget/modules/PowerMenuButton.tsx | 17 +++++++++++ widget/modules/export.ts | 6 ++++ 5 files changed, 70 insertions(+), 38 deletions(-) create mode 100644 widget/modules/LauncherButton.tsx create mode 100644 widget/modules/MediaPlayerButton.tsx create mode 100644 widget/modules/PowerMenuButton.tsx diff --git a/widget/Bar.tsx b/widget/Bar.tsx index eea21af..638499a 100644 --- a/widget/Bar.tsx +++ b/widget/Bar.tsx @@ -1,6 +1,4 @@ import { App, Astal, Gtk, Gdk } from "astal/gtk3"; -import Mpris from "gi://AstalMpris"; -import { bind } from "astal"; import { PowerMenu, Cpu, @@ -8,17 +6,17 @@ import { Ram, Storage, Workspaces, - FocusedClient, + // FocusedClient, Time, SysTray, Media, + LauncherButton, + PowerMenuButton, + MediaPlayerButton, } from "./modules/export"; -import { close_all_menus } from "./utils/windows"; export default function Bar(gdkmonitor: Gdk.Monitor) { const { TOP, LEFT, RIGHT } = Astal.WindowAnchor; - const mpris = Mpris.get_default(); - return ( <> - + @@ -47,34 +39,11 @@ export default function Bar(gdkmonitor: Gdk.Monitor) { - {bind(mpris, "players").as((ps) => - ps[0] ? ( - - ) : ( - <> - ), - )} + diff --git a/widget/modules/LauncherButton.tsx b/widget/modules/LauncherButton.tsx new file mode 100644 index 0000000..956314c --- /dev/null +++ b/widget/modules/LauncherButton.tsx @@ -0,0 +1,13 @@ +import { Gtk } from "astal/gtk3"; + +export default function LauncherButton() { + return ( + + ); +} diff --git a/widget/modules/MediaPlayerButton.tsx b/widget/modules/MediaPlayerButton.tsx new file mode 100644 index 0000000..c898c73 --- /dev/null +++ b/widget/modules/MediaPlayerButton.tsx @@ -0,0 +1,27 @@ +import Mpris from "gi://AstalMpris"; +import { bind } from "astal"; +import { close_all_menus } from "../utils/windows"; +import { App } from "astal/gtk3"; + +export default function MediaPlayerButton() { + const mpris = Mpris.get_default(); + return ( + <> + {bind(mpris, "players").as((ps) => + ps[0] ? ( + + ) : ( + <> + ), + )} + + ); +} diff --git a/widget/modules/PowerMenuButton.tsx b/widget/modules/PowerMenuButton.tsx new file mode 100644 index 0000000..028f2ee --- /dev/null +++ b/widget/modules/PowerMenuButton.tsx @@ -0,0 +1,17 @@ +import { close_all_menus } from "../utils/windows"; +import { App, Gtk } from "astal/gtk3"; + +export default function PowerMenuButton() { + return ( + + ); +} diff --git a/widget/modules/export.ts b/widget/modules/export.ts index dd41294..819130f 100644 --- a/widget/modules/export.ts +++ b/widget/modules/export.ts @@ -8,6 +8,9 @@ import SysTray from "./SysTray"; import Time from "./Time"; import Workspaces from "./Workspaces"; import Media from "./Media/Media"; +import LauncherButton from "./LauncherButton"; +import PowerMenuButton from "./PowerMenuButton"; +import MediaPlayerButton from "./MediaPlayerButton"; export { BatteryLevel, @@ -20,4 +23,7 @@ export { Time, Workspaces, Media, + LauncherButton, + PowerMenuButton, + MediaPlayerButton, };