2025-01-06 10:05:16 -05:00
|
|
|
import { App, Astal, Gdk, Gtk } from 'astal/gtk4';
|
2024-12-31 23:54:29 -05:00
|
|
|
import { Variable } from 'astal';
|
|
|
|
|
2025-01-05 20:23:44 -05:00
|
|
|
import Kompass from 'gi://Kompass';
|
|
|
|
|
2025-01-06 10:05:16 -05:00
|
|
|
import { Box, Calendar, CenterBox, Label, MenuButton, Popover, Window } from './subclasses';
|
2024-12-31 23:54:29 -05:00
|
|
|
|
|
|
|
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 = (
|
2025-01-01 02:55:15 -05:00
|
|
|
<Box
|
2024-12-31 23:54:29 -05:00
|
|
|
css={time().as((t) => `* { background: red; min-height: 10px; min-width: ${t}px; }`)}
|
|
|
|
/>
|
2025-01-01 02:55:15 -05:00
|
|
|
) as Box;
|
2024-12-31 23:54:29 -05:00
|
|
|
|
|
|
|
return (
|
2025-01-01 13:38:44 -05:00
|
|
|
<Window
|
2024-12-31 23:54:29 -05:00
|
|
|
visible
|
|
|
|
cssClasses={['Bar']}
|
|
|
|
exclusivity={EXCLUSIVE}
|
|
|
|
anchor={TOP | LEFT | RIGHT}
|
|
|
|
application={App}
|
|
|
|
>
|
2025-01-01 02:55:15 -05:00
|
|
|
<CenterBox cssName="centerbox">
|
2025-01-06 10:05:16 -05:00
|
|
|
<Kompass.Tray cursor={Gdk.Cursor.new_from_name('pointer', null)} />
|
2024-12-31 23:54:29 -05:00
|
|
|
|
|
|
|
{styledBox}
|
|
|
|
|
2025-01-01 13:38:44 -05:00
|
|
|
<MenuButton
|
2025-01-06 10:05:16 -05:00
|
|
|
cursor={Gdk.Cursor.new_from_name('pointer', null)}
|
2024-12-31 23:54:29 -05:00
|
|
|
hexpand
|
|
|
|
halign={CENTER}
|
|
|
|
>
|
2025-01-01 13:38:44 -05:00
|
|
|
<Label label={time().as(String)} />
|
|
|
|
<Popover>
|
|
|
|
<Calendar />
|
|
|
|
</Popover>
|
|
|
|
</MenuButton>
|
2025-01-01 02:55:15 -05:00
|
|
|
</CenterBox>
|
2025-01-01 13:38:44 -05:00
|
|
|
</Window>
|
2024-12-31 23:54:29 -05:00
|
|
|
);
|
|
|
|
};
|