From 2a6b0a1bb29ebb40502c16b4adbcd6607709e036 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Thu, 21 Nov 2024 10:32:18 -0500 Subject: [PATCH] feat(ags): add anims to current-client --- nixosModules/ags/config/widgets/bar/binto.tsx | 2 +- .../widgets/bar/items/current-client.tsx | 45 ++++++++++++------- .../config/widgets/bar/items/current-icon.tsx | 37 +++++++++------ 3 files changed, 52 insertions(+), 32 deletions(-) diff --git a/nixosModules/ags/config/widgets/bar/binto.tsx b/nixosModules/ags/config/widgets/bar/binto.tsx index f53540b3..be063eb8 100644 --- a/nixosModules/ags/config/widgets/bar/binto.tsx +++ b/nixosModules/ags/config/widgets/bar/binto.tsx @@ -26,7 +26,7 @@ export default () => ( - + {/* */} diff --git a/nixosModules/ags/config/widgets/bar/items/current-client.tsx b/nixosModules/ags/config/widgets/bar/items/current-client.tsx index 4657e54e..24a5ed32 100644 --- a/nixosModules/ags/config/widgets/bar/items/current-client.tsx +++ b/nixosModules/ags/config/widgets/bar/items/current-client.tsx @@ -1,4 +1,5 @@ import { bind, Variable } from 'astal'; +import { Gtk } from 'astal/gtk3'; import AstalApps from 'gi://AstalApps'; import AstalHyprland from 'gi://AstalHyprland'; @@ -15,12 +16,14 @@ export default () => { const focusedIcon = Variable(''); const focusedTitle = Variable(''); - let lastFocused: string | undefined; + let lastFocusedAddress: string | null; + const updateVars = ( client: AstalHyprland.Client | null = hyprland.get_focused_client(), ) => { - lastFocused = client?.get_address(); + lastFocusedAddress = client ? client.get_address() : null; + const app = applications.fuzzy_query( client?.get_class() ?? '', )[0]; @@ -37,7 +40,7 @@ export default () => { focusedTitle.set(client?.get_title() ?? ''); const id = client?.connect('notify::title', (c) => { - if (c.get_address() !== lastFocused) { + if (c.get_address() !== lastFocusedAddress) { c.disconnect(id); } focusedTitle.set(c.get_title()); @@ -57,22 +60,30 @@ export default () => { }); return ( - title !== '')} + title !== '')} > - + + + + - + + + - + + ); }; diff --git a/nixosModules/ags/config/widgets/bar/items/current-icon.tsx b/nixosModules/ags/config/widgets/bar/items/current-icon.tsx index 7883b032..8deee949 100644 --- a/nixosModules/ags/config/widgets/bar/items/current-icon.tsx +++ b/nixosModules/ags/config/widgets/bar/items/current-icon.tsx @@ -1,8 +1,10 @@ import { bind, Variable } from 'astal'; +import { Gtk } from 'astal/gtk3'; import AstalApps from 'gi://AstalApps'; import AstalHyprland from 'gi://AstalHyprland'; +import Separator from '../../misc/separator'; import { hyprMessage } from '../../../lib'; @@ -13,15 +15,16 @@ export default () => { const visibleIcon = Variable(false); const focusedIcon = Variable(''); - let lastFocused: string | undefined; + let lastFocusedAddress: string | null; const updateVars = ( client: AstalHyprland.Client | null = hyprland.get_focused_client(), ) => { - lastFocused = client?.get_address(); - const app = applications.fuzzy_query( - client?.get_class() ?? '', - )[0]; + lastFocusedAddress = client ? client.get_address() : null; + + const app = client ? + applications.fuzzy_query(client.get_class())[0] : + null; const icon = app?.iconName; @@ -34,7 +37,7 @@ export default () => { } const id = client?.connect('notify::title', (c) => { - if (c.get_address() !== lastFocused) { + if (c.get_address() !== lastFocusedAddress) { c.disconnect(id); } }); @@ -53,14 +56,20 @@ export default () => { }); return ( - - - + + + + + + + + ); };