From 68e6eddd225d9dc17e2c152c5e117a3df0a83186 Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Mon, 30 Jun 2025 00:39:34 +0100 Subject: [PATCH] Update astal Signed-off-by: Nikolaos Karaolidis --- flake.lock | 31 +++++++++--- flake.nix | 6 --- .../configs/user/gui/astal/config/app.ts | 12 ++--- .../configs/user/gui/astal/config/lib.ts | 4 +- .../user/gui/astal/config/package.json | 3 +- .../user/gui/astal/config/tsconfig.json | 10 ++-- .../user/gui/astal/config/widget/Center.tsx | 10 ++-- .../user/gui/astal/config/widget/Left.tsx | 13 ++--- .../user/gui/astal/config/widget/Right.tsx | 11 +++-- .../config/widget/components/Battery.tsx | 18 +++---- .../astal/config/widget/components/Date.tsx | 15 ++---- .../astal/config/widget/components/Hidden.tsx | 19 +++---- .../config/widget/components/Launcher.tsx | 8 +-- .../astal/config/widget/components/Tray.tsx | 37 +++++++------- .../config/widget/components/Workspaces.tsx | 49 +++++++++++-------- 15 files changed, 132 insertions(+), 114 deletions(-) diff --git a/flake.lock b/flake.lock index 6c348f0..711436a 100644 --- a/flake.lock +++ b/flake.lock @@ -5,23 +5,23 @@ "astal": [ "astal" ], + "gnim": "gnim", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1744557573, - "narHash": "sha256-XAyj0iDuI51BytJ1PwN53uLpzTDdznPDQFG4RwihlTQ=", + "lastModified": 1751192975, + "narHash": "sha256-X2WQxQZX9aktyaFQW94a4eCO0BYkLm9FZr9dyjVS7Sg=", "owner": "aylur", "repo": "ags", - "rev": "3ed9737bdbc8fc7a7c7ceef2165c9109f336bff6", + "rev": "74cdd7eabf0884a7d5ba0b300849891a7e89697e", "type": "github" }, "original": { "owner": "aylur", "ref": "main", "repo": "ags", - "rev": "3ed9737bdbc8fc7a7c7ceef2165c9109f336bff6", "type": "github" } }, @@ -32,18 +32,17 @@ ] }, "locked": { - "lastModified": 1749559749, - "narHash": "sha256-TM95tg1G7S6rVBBoMwurXMz8Il4xlnuZ2TI4h6lfZzg=", + "lastModified": 1751126708, + "narHash": "sha256-AodIKw7TmI7rHVcOfEsO82stupMYIMVQeLAUQfVxnkU=", "owner": "aylur", "repo": "astal", - "rev": "dd8a4662f2f17fb4326a7bd0fb2d054f5d477ba3", + "rev": "ac90f09385a2295da9fdc108aaba4a317aaeacc7", "type": "github" }, "original": { "owner": "aylur", "ref": "main", "repo": "astal", - "rev": "dd8a4662f2f17fb4326a7bd0fb2d054f5d477ba3", "type": "github" } }, @@ -110,6 +109,22 @@ "type": "github" } }, + "gnim": { + "flake": false, + "locked": { + "lastModified": 1751120710, + "narHash": "sha256-sT1ILM8m1QG8CeMmqLHhW/8T/MzUq3JL9jO3V7FMa4w=", + "owner": "aylur", + "repo": "gnim", + "rev": "5d2b734be452e2819f3a7313dbb34fa43c23e5d9", + "type": "github" + }, + "original": { + "owner": "aylur", + "repo": "gnim", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 96c343d..a188bb7 100644 --- a/flake.nix +++ b/flake.nix @@ -99,9 +99,6 @@ repo = "astal"; ref = "main"; - # TODO: Update - rev = "dd8a4662f2f17fb4326a7bd0fb2d054f5d477ba3"; - inputs.nixpkgs.follows = "nixpkgs"; }; @@ -111,9 +108,6 @@ repo = "ags"; ref = "main"; - # TODO: Update - rev = "3ed9737bdbc8fc7a7c7ceef2165c9109f336bff6"; - inputs = { nixpkgs.follows = "nixpkgs"; astal.follows = "astal"; diff --git a/hosts/common/configs/user/gui/astal/config/app.ts b/hosts/common/configs/user/gui/astal/config/app.ts index 4ad657e..5d08b1c 100644 --- a/hosts/common/configs/user/gui/astal/config/app.ts +++ b/hosts/common/configs/user/gui/astal/config/app.ts @@ -1,6 +1,6 @@ -import { App } from "astal/gtk3"; -import { monitorFile } from "astal/file"; -import { exec } from "astal/process"; +import app from "ags/gtk3/app"; +import { exec } from "ags/process"; +import { monitorFile } from "ags/file"; import GLib from "gi://GLib"; import Left from "./widget/Left"; import Center from "./widget/Center"; @@ -12,15 +12,15 @@ const scss = `${HOME}/.config/astal/theme.sass`; monitorFile(scss, () => { exec(`sassc ${scss} ${css}`); - App.apply_css(css, true); + app.apply_css(css, true); }); exec(`sassc ${scss} ${css}`); -App.start({ +app.start({ css, main() { - App.get_monitors().map((monitor) => { + app.get_monitors().map((monitor) => { Left(monitor); Center(monitor); Right(monitor); diff --git a/hosts/common/configs/user/gui/astal/config/lib.ts b/hosts/common/configs/user/gui/astal/config/lib.ts index ec7fa77..b5baa97 100644 --- a/hosts/common/configs/user/gui/astal/config/lib.ts +++ b/hosts/common/configs/user/gui/astal/config/lib.ts @@ -1,8 +1,8 @@ -import { Gdk } from "astal/gtk3"; +import { Gdk } from "ags/gtk3"; import Hyprland from "gi://AstalHyprland"; export const range = (length: number, start = 1) => { - return Array.from({ length }, (n, i) => i + start); + return Array.from({ length }, (_, i) => i + start); }; export const getHyprlandMonitor = (gdkmonitor: Gdk.Monitor) => { diff --git a/hosts/common/configs/user/gui/astal/config/package.json b/hosts/common/configs/user/gui/astal/config/package.json index a4b7093..9805e00 100644 --- a/hosts/common/configs/user/gui/astal/config/package.json +++ b/hosts/common/configs/user/gui/astal/config/package.json @@ -1,6 +1,5 @@ { - "name": "astal-shell", "dependencies": { - "astal": "~/.local/share/ags" + "ags": "*" } } diff --git a/hosts/common/configs/user/gui/astal/config/tsconfig.json b/hosts/common/configs/user/gui/astal/config/tsconfig.json index 406d60d..2a39620 100644 --- a/hosts/common/configs/user/gui/astal/config/tsconfig.json +++ b/hosts/common/configs/user/gui/astal/config/tsconfig.json @@ -1,12 +1,12 @@ { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "experimentalDecorators": true, - "strict": true, - "target": "ES2022", + "jsx": "react-jsx", + "jsxImportSource": "ags/gtk3", + "lib": ["ES2023"], "module": "ES2022", "moduleResolution": "Bundler", - "jsx": "react-jsx", - "jsxImportSource": "astal/gtk3" + "strict": true, + "target": "ES2020" } } diff --git a/hosts/common/configs/user/gui/astal/config/widget/Center.tsx b/hosts/common/configs/user/gui/astal/config/widget/Center.tsx index f86e7e8..5c2a797 100644 --- a/hosts/common/configs/user/gui/astal/config/widget/Center.tsx +++ b/hosts/common/configs/user/gui/astal/config/widget/Center.tsx @@ -1,17 +1,19 @@ -import { App, Astal, Gtk, Gdk } from "astal/gtk3"; +import { Astal, Gtk, Gdk } from "ags/gtk3"; import Date from "./components/Date"; import Hidden from "./components/Hidden"; +import app from "ags/gtk3/app"; export default (monitor: Gdk.Monitor) => ( - + diff --git a/hosts/common/configs/user/gui/astal/config/widget/Left.tsx b/hosts/common/configs/user/gui/astal/config/widget/Left.tsx index 2644def..0bacf52 100644 --- a/hosts/common/configs/user/gui/astal/config/widget/Left.tsx +++ b/hosts/common/configs/user/gui/astal/config/widget/Left.tsx @@ -1,21 +1,22 @@ -import { App, Astal, Gtk, Gdk } from "astal/gtk3"; +import { Astal, Gtk, Gdk } from "ags/gtk3"; +import app from "ags/gtk3/app"; import Launcher from "./components/Launcher"; import Workspace from "./components/Workspaces"; import Hidden from "./components/Hidden"; -import { getHyprlandMonitor } from "../lib"; export default (monitor: Gdk.Monitor) => ( - + - + diff --git a/hosts/common/configs/user/gui/astal/config/widget/Right.tsx b/hosts/common/configs/user/gui/astal/config/widget/Right.tsx index 07cbb1b..e949181 100644 --- a/hosts/common/configs/user/gui/astal/config/widget/Right.tsx +++ b/hosts/common/configs/user/gui/astal/config/widget/Right.tsx @@ -1,18 +1,21 @@ -import { App, Astal, Gtk, Gdk } from "astal/gtk3"; +import { Astal, Gtk } from "ags/gtk3"; +import app from "ags/gtk3/app"; +import Gdk from "gi://Gdk"; import Systray from "./components/Tray"; import Hidden from "./components/Hidden"; import Battery from "./components/Battery"; export default (monitor: Gdk.Monitor) => ( - + diff --git a/hosts/common/configs/user/gui/astal/config/widget/components/Battery.tsx b/hosts/common/configs/user/gui/astal/config/widget/components/Battery.tsx index c67fe7c..383e7b6 100644 --- a/hosts/common/configs/user/gui/astal/config/widget/components/Battery.tsx +++ b/hosts/common/configs/user/gui/astal/config/widget/components/Battery.tsx @@ -1,4 +1,4 @@ -import { bind, Variable } from "astal"; +import { createBinding, createComputed } from "ags"; import AstalBattery from "gi://AstalBattery"; const battery = AstalBattery.get_default(); @@ -9,19 +9,19 @@ const formatTime = (seconds: number) => : "--:--"; export default () => { - const percentage = bind(battery, "percentage").as( + const percentage = createBinding(battery, "percentage").as( (p) => Math.round(p * 100) + "%", ); - const charging = bind(battery, "charging"); - const timeToFull = bind(battery, "timeToFull"); - const timeToEmpty = bind(battery, "timeToEmpty"); + const charging = createBinding(battery, "charging"); + const timeToFull = createBinding(battery, "timeToFull"); + const timeToEmpty = createBinding(battery, "timeToEmpty"); - const time = Variable.derive( + const time = createComputed( [charging, timeToFull, timeToEmpty], (charging, full, empty) => formatTime(charging ? full : empty), ); - const label = Variable.derive( + const label = createComputed( [percentage, charging, time], (percentage, charging, time) => { const arrow = charging ? "▲" : "▼"; @@ -30,8 +30,8 @@ export default () => { ); return ( - ); }; diff --git a/hosts/common/configs/user/gui/astal/config/widget/components/Date.tsx b/hosts/common/configs/user/gui/astal/config/widget/components/Date.tsx index 174436e..6987c91 100644 --- a/hosts/common/configs/user/gui/astal/config/widget/components/Date.tsx +++ b/hosts/common/configs/user/gui/astal/config/widget/components/Date.tsx @@ -1,21 +1,16 @@ -import { bind, Variable } from "astal"; -import { GLib } from "astal"; +import { createPoll } from "ags/time"; +import GLib from "gi://GLib?version=2.0"; export default () => { - const time = Variable( + const time = createPoll( GLib.DateTime.new_now_local().format("%H:%M - %A, %d %B %Y")!, - ).poll( 1000, () => GLib.DateTime.new_now_local().format("%H:%M - %A, %d %B %Y")!, ); return ( - ); }; diff --git a/hosts/common/configs/user/gui/astal/config/widget/components/Hidden.tsx b/hosts/common/configs/user/gui/astal/config/widget/components/Hidden.tsx index 5b9272c..975f90e 100644 --- a/hosts/common/configs/user/gui/astal/config/widget/components/Hidden.tsx +++ b/hosts/common/configs/user/gui/astal/config/widget/components/Hidden.tsx @@ -1,5 +1,6 @@ -import { Gtk } from "astal/gtk3"; -import { Variable, bind, timeout } from "astal"; +import { createState } from "ags"; +import { Gtk } from "ags/gtk3"; +import { timeout } from "ags/time"; export default function Hidden({ child, @@ -12,24 +13,20 @@ export default function Hidden({ orientation?: Gtk.Orientation; transitionType?: Gtk.RevealerTransitionType; }) { - const show = Variable(true); + const [show, setShow] = createState(true); const contents = child ?? children; return ( - show.set(true)} - onHoverLost={() => show.set(false)} - > + setShow(true)} onHoverLost={() => setShow(false)}> timeout(2000, () => (self.revealChild = false))} - revealChild={bind(show)} + onRealize={() => timeout(2000, () => setShow(false))} + revealChild={show} transitionType={transitionType} > {Array.isArray(contents) ? <>{contents} : contents} - + ); diff --git a/hosts/common/configs/user/gui/astal/config/widget/components/Launcher.tsx b/hosts/common/configs/user/gui/astal/config/widget/components/Launcher.tsx index b4f83a9..24cb561 100644 --- a/hosts/common/configs/user/gui/astal/config/widget/components/Launcher.tsx +++ b/hosts/common/configs/user/gui/astal/config/widget/components/Launcher.tsx @@ -1,14 +1,14 @@ -import { execAsync } from "astal/process"; +import { execAsync } from "ags/process"; export default () => ( ); diff --git a/hosts/common/configs/user/gui/astal/config/widget/components/Tray.tsx b/hosts/common/configs/user/gui/astal/config/widget/components/Tray.tsx index 3a01c32..7d12736 100644 --- a/hosts/common/configs/user/gui/astal/config/widget/components/Tray.tsx +++ b/hosts/common/configs/user/gui/astal/config/widget/components/Tray.tsx @@ -1,28 +1,31 @@ -import { App } from "astal/gtk3"; -import { bind } from "astal"; +import { createBinding, For } from "ags"; +import app from "ags/gtk3/app"; import Tray from "gi://AstalTray"; const tray = Tray.get_default(); const TrayButton = ({ item }: { item: Tray.TrayItem }) => ( ["dbusmenu", ag])} + menuModel={createBinding(item, "menuModel")} > - + ); -export default () => ( - - {bind(tray, "items").as((items) => - items.map((item) => { - if (item.iconThemePath) App.add_icons(item.iconThemePath); - return ; - }), - )} - -); +export default () => { + let items = createBinding(tray, "items"); + + return ( + + + {(item, _) => { + if (item.iconThemePath) app.add_icons(item.iconThemePath); + return ; + }} + + + ); +}; diff --git a/hosts/common/configs/user/gui/astal/config/widget/components/Workspaces.tsx b/hosts/common/configs/user/gui/astal/config/widget/components/Workspaces.tsx index 43b69b9..61e35e1 100644 --- a/hosts/common/configs/user/gui/astal/config/widget/components/Workspaces.tsx +++ b/hosts/common/configs/user/gui/astal/config/widget/components/Workspaces.tsx @@ -1,74 +1,83 @@ -import { bind, Variable } from "astal"; import Hyprland from "gi://AstalHyprland"; -import { range } from "../../lib"; +import { getHyprlandMonitor, range } from "../../lib"; +import { + Accessor, + createBinding, + createComputed, + createState, + Setter, +} from "ags"; +import { Gdk, Gtk } from "ags/gtk3"; const hyprland = Hyprland.get_default(); const BLOCK_SIZE = 10; const Workspace = ({ id }: { id: number }) => { - let clients: Variable; + let clients: Accessor; + let setClients: Setter; try { const workspace = hyprland.get_workspace(id); - clients = Variable(workspace.clients.map((client) => client.address)); + [clients, setClients] = createState( + workspace.clients.map((client) => client.address), + ); } catch (_) { - clients = Variable([]); + [clients, setClients] = createState([]); } - const active = Variable.derive( - [bind(hyprland, "focusedWorkspace")], + const active = createComputed( + [createBinding(hyprland, "focusedWorkspace")], (focused) => focused.id == id, ); hyprland.connect("workspace-added", (_, workspace) => { if (workspace.id != id) return; - clients.set(workspace.clients.map((client) => client.address)); + setClients(workspace.clients.map((client) => client.address)); }); hyprland.connect("workspace-removed", (_, workspaceId) => { if (workspaceId != id) return; - clients.set([]); + setClients([]); }); hyprland.connect("client-added", (_hyprland, client) => { if (client.workspace.id != id) return; - clients.set([...clients.get(), client.address]); + setClients([...clients.get(), client.address]); }); - // Explicit separate event handling instead of Variable.derive(workspaces, clients) - // because client-moved events appear to be broken if done that way. hyprland.connect("client-moved", (_hyprland, client, workspace) => { if (workspace.id == id) { - clients.set([...clients.get(), client.address]); + setClients([...clients.get(), client.address]); } else { - clients.set( + setClients( clients.get().filter((oldClient) => oldClient != client.address), ); } }); hyprland.connect("client-removed", (_hyprland, address) => { - clients.set(clients.get().filter((oldClient) => oldClient != address)); + setClients(clients.get().filter((oldClient) => oldClient != address)); }); - const className = Variable.derive([active, clients], (active, clients) => { + const className = createComputed([active, clients], (active, clients) => { if (active) return "button active"; if (clients.length > 0) return "button occupied"; return "button"; }); return ( - + hyprland.dispatch("workspace", `${id}`)}> - ); }; -export default ({ monitor }: { monitor: Hyprland.Monitor }) => { +export default ({ gdkmonitor }: { gdkmonitor: Gdk.Monitor }) => { + const monitor = getHyprlandMonitor(gdkmonitor)!; const workspaces = hyprland.get_workspaces(); const displayWorkspaces = workspaces.filter( (w) => w.monitor.id === monitor.id, @@ -78,7 +87,7 @@ export default ({ monitor }: { monitor: Hyprland.Monitor }) => { return ( { hyprland.dispatch("workspace", e.delta_y > 0 ? "m+1" : "m-1"); }}