nixos-configs/modules/ags/config/ts/bar/items/current-window.ts

35 lines
887 B
TypeScript
Raw Normal View History

const Applications = await Service.import('applications');
const Hyprland = await Service.import('hyprland');
const { Box, Icon, Label } = Widget;
import Separator from '../../misc/separator.ts';
2023-12-05 12:04:08 -05:00
const SPACING = 8;
2023-12-05 12:04:08 -05:00
export default () => Box({
class_name: 'current-window',
2023-12-05 12:04:08 -05:00
children: [
Separator(SPACING / 2),
2023-12-18 18:00:30 -05:00
Icon({ size: 30 })
.hook(Hyprland.active.client, (self) => {
const app = Applications
.query(Hyprland.active.client.class)[0];
self.icon = app?.icon_name || '';
2023-12-18 18:00:30 -05:00
}),
2023-12-05 12:04:08 -05:00
Separator(SPACING),
Label({
css: 'color: #CBA6F7; font-size: 18px',
truncate: 'end',
2023-12-18 18:00:30 -05:00
label: Hyprland.active.client.bind('title'),
2023-12-05 12:04:08 -05:00
}),
],
}).hook(Hyprland.active.client, (self) => {
self.visible = Hyprland.active.client.title !== '';
});