From 4e545f07ef41f137882fc388d35b51135262f679 Mon Sep 17 00:00:00 2001 From: nat Date: Mon, 3 Mar 2025 19:04:14 -0800 Subject: [PATCH] make clock use builtin python functions instead of a shell --- widgets/bar/clock.hy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/widgets/bar/clock.hy b/widgets/bar/clock.hy index 1732441..0ddcd80 100644 --- a/widgets/bar/clock.hy +++ b/widgets/bar/clock.hy @@ -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))])))