nixos-configs/nixosModules/ags/v2/widgets/bar/items/current-client.tsx
matt1432 af10d27e1b
All checks were successful
Discord / discord commits (push) Has been skipped
feat(agsV2): add current-client
2024-09-27 16:35:32 -04:00

48 lines
1.3 KiB
TypeScript

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 (
<box
className="bar-item current-window"
visible={focused.as(Boolean)}
>
<icon
css="font-size: 32px;"
setup={(self: Widget.Icon) => {
self.hook(Hyprland, 'notify::focused-client', () => {
const app = Applications.query(
Hyprland.get_focused_client().get_class(),
false,
)[0];
self.set_icon(app.iconName ?? '');
});
}}
/>
<Separator size={SPACING} />
{focused.as((client) => (client && (
<label
label={bind(client, 'title').as(String)}
truncate={Pango.EllipsizeMode.END}
/>
)))}
</box>
);
};