elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.42k stars 382 forks source link

[FEATURE] EWW_TIME - builtin clock #791

Closed sapphire-arches closed 1 year ago

sapphire-arches commented 1 year ago

Description of the requested feature

It would be nice if EWW provided EWW_TIME, similar to EWW_RAM or EWW_CPU. This would eliminate the only remaining polled shell script from my configuration which probably isn't super important but would be nice.

Proposed configuration syntax

It would be nice to support multiple time zones, so perhaps rather than a single global EWW_TIME variable we would use something like:

(deftime NY :zone "America/New_York")

This adds another top-level construct which might conflict with existing configs, but I think the def* namespace is already pseudo-reserved so hopefully it's fine.

It would be used like this:

(defwidget clock
  (box
    (box {NY.year})
    (box {NY.month})
    (box {NY.day})
    (box {NY.hour})
    (box {NY.minute})
    (box {NY.second})))

We can provide milliseconds and microseconds for the truly time-obsessed as well (assuming it's cheap) but I don't expect those will get used much.

Additional context

I can probably put some time in to implementing this, assuming the design outlined above looks OK.

Stetsed commented 1 year ago

I think this would be a useful feature to provide as it's also something that is VERY common to be used inside of an eww widget.

HardoMX commented 1 year ago

That would be really nice. Would maybe also be nice to include a way to get either the name of the month, or the number, i.e {NY.month} would give the number, e.g "05", but {NY.month.name} (or something like it) would give "May". And the same for days, either weekday or date

sapphire-arches commented 1 year ago

Some other notes on what we should at least consider when designing the interface:

I think all of this can be handled by adding arguments to deftime.