From af10d27e1b0c4cbc86d77b9fe57bbccb5de73ed8 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Fri, 27 Sep 2024 16:35:32 -0400 Subject: [PATCH] feat(agsV2): add current-client --- .../ags/v2/widgets/bar/fullscreen.tsx | 2 +- .../ags/v2/widgets/bar/items/battery.tsx | 2 +- .../v2/widgets/bar/items/current-client.tsx | 48 +++++++++++++++++++ nixosModules/ags/v2/widgets/bar/style.scss | 2 +- nixosModules/ags/v2/widgets/bar/wim.tsx | 7 +++ 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 nixosModules/ags/v2/widgets/bar/items/current-client.tsx diff --git a/nixosModules/ags/v2/widgets/bar/fullscreen.tsx b/nixosModules/ags/v2/widgets/bar/fullscreen.tsx index eebc0f2d..9ae89b65 100644 --- a/nixosModules/ags/v2/widgets/bar/fullscreen.tsx +++ b/nixosModules/ags/v2/widgets/bar/fullscreen.tsx @@ -1,6 +1,6 @@ import { Astal, bind, Gdk, Gtk, Variable, Widget } from 'astal'; -import AstalHyprland from 'gi://AstalHyprland?version=0.1'; +import AstalHyprland from 'gi://AstalHyprland?version=0.1'; const Hyprland = AstalHyprland.get_default(); import { get_hyprland_monitor_desc, get_monitor_desc } from '../../lib'; diff --git a/nixosModules/ags/v2/widgets/bar/items/battery.tsx b/nixosModules/ags/v2/widgets/bar/items/battery.tsx index 18d1040c..2b8c84c8 100644 --- a/nixosModules/ags/v2/widgets/bar/items/battery.tsx +++ b/nixosModules/ags/v2/widgets/bar/items/battery.tsx @@ -7,7 +7,7 @@ import Separator from '../../misc/separator'; const LOW_BATT = 20; -const SPACING = 5; +const SPACING = 8; export default () => ( diff --git a/nixosModules/ags/v2/widgets/bar/items/current-client.tsx b/nixosModules/ags/v2/widgets/bar/items/current-client.tsx new file mode 100644 index 00000000..e355bee0 --- /dev/null +++ b/nixosModules/ags/v2/widgets/bar/items/current-client.tsx @@ -0,0 +1,48 @@ +import { bind, Widget } from 'astal'; + +import Pango from 'gi://Pango?version=1.0'; + +import AstalApps from 'gi://AstalApps?version=0.1'; +const Applications = AstalApps.Apps.new(); + +import AstalHyprland from 'gi://AstalHyprland?version=0.1'; +const Hyprland = AstalHyprland.get_default(); + +import Separator from '../../misc/separator'; + + +const SPACING = 8; + +export default () => { + const focused = bind(Hyprland, 'focusedClient'); + + return ( + + { + self.hook(Hyprland, 'notify::focused-client', () => { + const app = Applications.query( + Hyprland.get_focused_client().get_class(), + false, + )[0]; + + self.set_icon(app.iconName ?? ''); + }); + }} + /> + + + + {focused.as((client) => (client && ( + + ); +}; diff --git a/nixosModules/ags/v2/widgets/bar/style.scss b/nixosModules/ags/v2/widgets/bar/style.scss index 15b20843..1c243a1b 100644 --- a/nixosModules/ags/v2/widgets/bar/style.scss +++ b/nixosModules/ags/v2/widgets/bar/style.scss @@ -1,6 +1,6 @@ .bar { .bar-item { - padding: 5px; + padding: 5px 10px 5px 10px; border-radius: 7px; background-color: darken($window_bg_color, 3%); font-size: 20px; diff --git a/nixosModules/ags/v2/widgets/bar/wim.tsx b/nixosModules/ags/v2/widgets/bar/wim.tsx index 558b9948..fed9fab5 100644 --- a/nixosModules/ags/v2/widgets/bar/wim.tsx +++ b/nixosModules/ags/v2/widgets/bar/wim.tsx @@ -1,8 +1,10 @@ import { Astal, Gtk } from 'astal'; import Battery from './items/battery'; +import CurrentClient from './items/current-client'; import BarRevealer from './fullscreen'; +import Separator from '../misc/separator'; export default () => { @@ -15,8 +17,10 @@ export default () => { Astal.WindowAnchor.RIGHT } > + + @@ -24,8 +28,11 @@ export default () => { + + + ); };