From 2c9ff9db2f274da3dbfb3791d08862840f2c1813 Mon Sep 17 00:00:00 2001 From: Bloxx12 Date: Mon, 21 Apr 2025 09:35:17 +0200 Subject: [PATCH] working bar --- flake.nix | 44 +++++++-------------- nodemon.json | 4 +- style.scss | 38 +++++++++++++----- widget/Bar.tsx | 90 ++++--------------------------------------- widget/battery.tsx | 14 +++++++ widget/systray.tsx | 22 +++++++++++ widget/time.tsx | 11 ++++++ widget/workspaces.tsx | 24 ++++++++++++ 8 files changed, 121 insertions(+), 126 deletions(-) create mode 100644 widget/battery.tsx create mode 100644 widget/systray.tsx create mode 100644 widget/time.tsx create mode 100644 widget/workspaces.tsx diff --git a/flake.nix b/flake.nix index 10cb05d..0c74b03 100644 --- a/flake.nix +++ b/flake.nix @@ -31,56 +31,38 @@ src = ./.; name = "my-shell"; entry = "app.ts"; - - # additional libraries and executables to add to gjs' runtime - extraPackages = [ - # ags.packages.${system}.battery - # pkgs.fzf - ]; }; }; devShells.${system} = { default = pkgs.mkShell { buildInputs = with pkgs; [ - nodejs_23 - gobject-introspection - json-glib - gjs # includes astal3 astal4 astal-io by default (ags.packages.${system}.default.override { extraPackages = builtins.attrValues { inherit (astal.packages.${system}) - hyprland - tray - network + io + astal4 battery + wireplumber + network + mpris + powerprofiles + tray + bluetooth + hyprland ; }; }) - wrapGAppsHook - gobject-introspection + nodejs_23 meson - pkg-config ninja - vala - gtk3 - gtk4 - gtk-layer-shell - gtk4-layer-shell - json-glib - pam - gvfs - networkmanager - gdk-pixbuf - wireplumber - libdbusmenu-gtk3 - wayland + pkg-config + gobject-introspection + wrapGAppsHook4 blueprint-compiler - libadwaita - wayland-scanner dart-sass esbuild gjs diff --git a/nodemon.json b/nodemon.json index 060c9f5..06889c7 100644 --- a/nodemon.json +++ b/nodemon.json @@ -1,5 +1,5 @@ { - "watch": ["app.ts", "widget/"], - "ext": "ts, tsx", + "watch": ["app.ts", "style.scss", "widget/"], + "ext": "ts, tsx, scss", "exec": "ags run --gtk4 ." } diff --git a/style.scss b/style.scss index 4db19a6..582bb08 100644 --- a/style.scss +++ b/style.scss @@ -1,17 +1,18 @@ // https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/theme/Adwaita/_colors-public.scss $fg-color: #{"@theme_fg_color"}; $bg-color: #{"@theme_bg_color"}; +$corner-size: 7; +$notch-color: #222; window.Bar { background: transparent; color: $fg-color; - font-weight: bold; + /* font-weight: bold; */ font-size: 25px; >centerbox { background: $bg-color; border-radius: 10px; - margin: 8px; } button { @@ -19,25 +20,42 @@ window.Bar { margin: 2px; } + .AudioSlider { + min-width: 200px; + } + .Workspaces { + background-color: black; + margin: 0 60px 10px 60px; + border-radius: 0 0 20px 20px; + button { all: unset; - background-color: transparent; - margin: 2px; - padding: 2px; + color: white; + + &.focused { + color: red; + border-color: blue; + } + + label { + transition: 200ms; + padding: 0 8px; + margin: 2px; + border-radius: 10px; + border: 1pt solid transparent; + } &:hover label { - background-color: red; + background-color: blue; border-color: $bg-color; } &:active label { - background-color: $fg-color; + background-color: green; + border-color: red; } - .focused { - color: red; - } } } } \ No newline at end of file diff --git a/widget/Bar.tsx b/widget/Bar.tsx index 0082bc0..c2be237 100644 --- a/widget/Bar.tsx +++ b/widget/Bar.tsx @@ -1,85 +1,10 @@ -import { App, Astal, Gtk, Gdk, Widget, astalify } from "astal/gtk4" -import { GLib, Variable } from "astal" -import Hyprland from "gi://AstalHyprland" -import Tray from "gi://AstalTray" -import Battery from "gi://AstalBattery" -import Network from "gi://AstalNetwork" -import AstalTray from "gi://AstalTray?version=0.1" +import { App, Astal, Gtk, Gdk, } from "astal/gtk4" +import Workspaces from "./workspaces" +import Systray from "./systray" +import Battery from "./battery" +import Time from "./time" -type Workspace = { - id: number - focus: () => void -} - -type Hyprland = { - workspaces: Workspace[] - focusedWorkspace: Workspace | null -} - -function Bat() { - const bat = Battery.get_default() - - return - Battery: {bat.get_percentage() * 100}% - - -} - -function Net() { - const network = Network.get_default() - - return - {network.wifi.enabled} - -} - -function Workspaces() { - const hypr = Hyprland.get_default() - - return - { - hypr.workspaces.filter(ws => !(ws.id >= -99 && ws.id < -2)) - .sort((a, b) => a.id - b.id) - .map(ws => ( - - )) - } - -} - -function SysTray() { - const tray = AstalTray.get_default() - - print(tray.get_items.length) - - return - {tray.get_items().map(item => ( - - - - ))} - -} - -function Time({ }) { - const time = Variable("").poll(1000, () => GLib.DateTime.new_now_local().format("%H:%M")!) - - return