make clock use builtin python functions instead of a shell

This commit is contained in:
nat
2025-03-03 19:04:14 -08:00
parent f64f06b35b
commit 4e545f07ef

View File

@ -1,9 +1,10 @@
(import astal *)
(import astal.gtk3 *)
(import datetime)
(let [
datetime (.poll (Variable "") 1000 "date +'%d %b %H:%M:%S'" (fn [out _] out))
unix-seconds (.poll (Variable "") 1000 "date +%s" (fn [out _] out))]
time (.poll (Variable "") 1000 (fn [_] (. datetime datetime (now) (strftime "%d %b %H:%M:%S"))) (fn [out] out))
unix-seconds (.poll (Variable "") 1000 (fn [_] (. datetime datetime (now) (strftime "%s"))) (fn [out] out))]
(setv clock (Widget.Box
:class-name "clock"
:vertical True
@ -11,7 +12,7 @@
:children [
(Widget.Label
:halign Gtk.Align.START
:label (bind datetime))
:label (bind time))
(Widget.Label
:halign Gtk.Align.START
:label (bind unix-seconds))])))