From df3b51399cbe82b083ef04230f3b340e12621afb Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Mon, 27 Jan 2025 21:55:02 +1100 Subject: sideright: make popdown window Weather requires a weather api key from https://weatherapi.com --- src/utils/system.ts | 6 +++++- src/utils/widgets.ts | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/utils') diff --git a/src/utils/system.ts b/src/utils/system.ts index c318c64..31e9cfd 100644 --- a/src/utils/system.ts +++ b/src/utils/system.ts @@ -1,4 +1,4 @@ -import { execAsync, GLib, type Gio } from "astal"; +import { bind, execAsync, GLib, Variable, type Gio } from "astal"; import type AstalApps from "gi://AstalApps"; import { osIcons } from "./icons"; @@ -63,3 +63,7 @@ export const osIcon = String.fromCodePoint( return 0xf31a; })() ); + +export const currentTime = Variable(GLib.DateTime.new_now_local()).poll(1000, () => GLib.DateTime.new_now_local()); +export const bindCurrentTime = (format: string, fallback?: (time: GLib.DateTime) => string) => + bind(currentTime).as(c => c.format(format) ?? fallback?.(c) ?? new Date().toLocaleString()); diff --git a/src/utils/widgets.ts b/src/utils/widgets.ts index 64325a0..454a7a6 100644 --- a/src/utils/widgets.ts +++ b/src/utils/widgets.ts @@ -50,3 +50,10 @@ export class MenuItem extends astalify(Gtk.MenuItem) { super(props as any); } } + +@register() +export class Calendar extends astalify(Gtk.Calendar) { + constructor(props: ConstructProps) { + super(props as any); + } +} -- cgit v1.2.3-freya