From 6893948ade9322516b32ada3e90765fe82e37f5d Mon Sep 17 00:00:00 2001 From: matt1432 Date: Tue, 5 Dec 2023 12:04:08 -0500 Subject: [PATCH] feat(bar currentclient): add icon --- .../ags/js/bar/buttons/current-window.js | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/devices/wim/config/ags/js/bar/buttons/current-window.js b/devices/wim/config/ags/js/bar/buttons/current-window.js index fd00002..adff88d 100644 --- a/devices/wim/config/ags/js/bar/buttons/current-window.js +++ b/devices/wim/config/ags/js/bar/buttons/current-window.js @@ -1,10 +1,32 @@ +import Applications from 'resource:///com/github/Aylur/ags/service/applications.js'; import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; -import { Label } from 'resource:///com/github/Aylur/ags/widget.js'; +import { Box, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js'; +import Separator from '../../misc/separator.js'; + +const SPACING = 8; -export default () => Label({ - css: 'color: #CBA6F7; font-size: 18px', - truncate: 'end', - binds: [['label', Hyprland.active.client, 'title']], +export default () => Box({ + children: [ + Separator(SPACING / 2), + + Icon({ + size: 30, + connections: [[Hyprland.active.client, (self) => { + const app = Applications.query(Hyprland.active.client.class)[0]; + + self.icon = app.iconName; + self.visible = Hyprland.active.client.title !== ''; + }]], + }), + + Separator(SPACING), + + Label({ + css: 'color: #CBA6F7; font-size: 18px', + truncate: 'end', + binds: [['label', Hyprland.active.client, 'title']], + }), + ], });