From 8f5ad70ed388bdf2065653fc3fefbc5f61b784b7 Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Mon, 10 Mar 2025 21:51:05 +0700 Subject: [PATCH] refactor and add modules directory --- style.scss | 14 ++++- widget/Bar.tsx | 87 +++++------------------------- widget/Ram.tsx | 13 ----- widget/modules/Battery.tsx | 14 +++++ widget/{ => modules}/Cpu.tsx | 6 +-- widget/modules/FocusedClient.tsx | 15 ++++++ widget/{ => modules}/PowerMenu.tsx | 0 widget/modules/Ram.tsx | 45 ++++++++++++++++ widget/modules/Storage.tsx | 33 ++++++++++++ widget/modules/SysTray.tsx | 18 +++++++ widget/modules/Time.tsx | 12 +++++ widget/modules/Workspaces.tsx | 21 ++++++++ widget/modules/export.ts | 21 ++++++++ 13 files changed, 209 insertions(+), 90 deletions(-) delete mode 100644 widget/Ram.tsx create mode 100644 widget/modules/Battery.tsx rename widget/{ => modules}/Cpu.tsx (82%) create mode 100644 widget/modules/FocusedClient.tsx rename widget/{ => modules}/PowerMenu.tsx (100%) create mode 100644 widget/modules/Ram.tsx create mode 100644 widget/modules/Storage.tsx create mode 100644 widget/modules/SysTray.tsx create mode 100644 widget/modules/Time.tsx create mode 100644 widget/modules/Workspaces.tsx create mode 100644 widget/modules/export.ts diff --git a/style.scss b/style.scss index da08fcb..b4d2e4b 100644 --- a/style.scss +++ b/style.scss @@ -66,8 +66,20 @@ window.Bar { } } + .Cpu { + padding: 0 5px; + } + + .Ram { + padding: 0 5px; + } + + .Storage { + padding: 0 5px; + } + .Focused { - padding: 0 15px; + padding: 0 15px 0 5px; transition: 300ms; } diff --git a/widget/Bar.tsx b/widget/Bar.tsx index fa6efe6..b7f0250 100644 --- a/widget/Bar.tsx +++ b/widget/Bar.tsx @@ -1,73 +1,15 @@ import { App, Astal, Gtk, Gdk } from "astal/gtk3" -import { Variable, GLib, bind } from "astal" -import Hyprland from "gi://AstalHyprland" -import Tray from "gi://AstalTray" -import PowerMenu from "./PowerMenu" -import Cpu from "./Cpu" - -const time = Variable("").poll(1000, "date") - -function Workspaces() { - const hypr = Hyprland.get_default() - - return - {bind(hypr, "workspaces").as(wss => wss - .filter(ws => !(ws.id >= -99 && ws.id <= -2)) // filter out special workspaces - .sort((a, b) => a.id - b.id) - .map(ws => ( - - )) - )} - -} - -function FocusedClient() { - const hypr = Hyprland.get_default() - const focused = bind(hypr, "focusedClient") - - return - {focused.as(client => ( - client && -} - -function Time({ format = "%H:%M - %A %e" }) { - const time = Variable("").poll(1000, () => - GLib.DateTime.new_now_local().format(format)!) - - return