diff options
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/system.ts | 6 | ||||
| -rw-r--r-- | src/utils/widgets.ts | 7 |
2 files changed, 12 insertions, 1 deletions
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<Calendar, Gtk.Calendar.ConstructorProps>) { + super(props as any); + } +} |