feat: add tray and time widget

This commit is contained in:
tux
2025-05-31 18:38:21 +05:30
parent 56a87702f6
commit d5a24064e9
4 changed files with 36 additions and 0 deletions

View File

@@ -33,6 +33,7 @@
hyprland
apps
battery
tray
];
};
@@ -51,6 +52,7 @@
hyprland
apps
battery
tray
];
})
];

View File

@@ -3,6 +3,8 @@ import { FocusedClient, WorkspaceButton } from "./workspace";
import { Battery } from "./battery";
import { Launcher } from "./launcher";
import { Tailscale } from "./tailscale";
import { Tray } from "./tray";
import { Time } from "./time";
export const WINDOW_NAME = "bar";
@@ -46,6 +48,8 @@ const End = () => {
<box spacing={15}>
<Tailscale />
<Battery />
<Tray />
<Time />
</box>
);
};

12
widget/bar/time.tsx Normal file
View File

@@ -0,0 +1,12 @@
import { GLib, Variable } from "astal";
export const Time = () => {
const time = Variable("").poll(
1000,
() => GLib.DateTime.new_now_local().format("%I:%M:%S %p")!,
);
return (
<label cssClasses={["time"]} onDestroy={() => time.drop()} label={time()} />
);
};

18
widget/bar/tray.tsx Normal file
View File

@@ -0,0 +1,18 @@
import { bind } from "astal";
import AstalTray from "gi://AstalTray";
export const Tray = () => {
const tray = AstalTray.get_default();
for (const item of tray.get_items()) {
print(item.title);
}
return (
<box cssClasses={["tray"]}>
{bind(tray, "items").as((items) =>
items.map((item) => <image gicon={bind(item, "gicon")} />),
)}
</box>
);
};