nixos-configs/modules/ags/gtk4/widget/bar.ts
matt1432 adb36c2b34
All checks were successful
Discord / discord commits (push) Has been skipped
refactor(ags4): use agsV1 syntax
2025-01-13 10:51:02 -05:00

49 lines
1.3 KiB
TypeScript

import { App, Astal, Gdk, Gtk } from 'astal/gtk4';
import { Variable } from 'astal';
import Kompass from 'gi://Kompass';
import { Box, Calendar, CenterBox, Label, MenuButton, Popover, Window } from './subclasses';
const { EXCLUSIVE } = Astal.Exclusivity;
const { TOP, LEFT, RIGHT } = Astal.WindowAnchor;
const { CENTER } = Gtk.Align;
const time = Variable(0);
setInterval(() => {
time.set(time.get() + 1);
}, 1000);
export default () => {
const styledBox = Box({
css: time().as((t) => `* { background: red; min-height: 10px; min-width: ${t}px; }`),
});
return Window({
visible: true,
cssClasses: ['Bar'],
exclusivity: EXCLUSIVE,
anchor: TOP | LEFT | RIGHT,
application: App,
child: CenterBox({
startWidget: new Kompass.Tray({
cursor: Gdk.Cursor.new_from_name('pointer', null),
}),
centerWidget: styledBox,
endWidget: MenuButton({
cursor: Gdk.Cursor.new_from_name('pointer', null),
hexpand: true,
halign: CENTER,
children: [
Label({ label: time().as(String) }),
Popover({ child: Calendar() }),
],
}),
}),
});
};