Highlight today in the calendar.

This commit is contained in:
Tom Alexander 2022-10-18 22:29:23 -04:00
parent 00920a0ec1
commit 5ccac6de3a
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 12 additions and 4 deletions

View File

@ -20,7 +20,7 @@
"spacing": 10
},
"custom/clock": {
"exec": "waybar_custom_clock 'America/New_York'",
"exec": "waybar_custom_clock",
"return-type": "json",
"restart-interval": 30
}

View File

@ -40,7 +40,7 @@ class Update:
@lru_cache(maxsize=1)
def make_calendar(today: datetime.date, tz: datetime.tzinfo):
def make_calendar(today: datetime.date):
width: Final[int] = 20
start_of_month = today.replace(day=1)
month_header = today.strftime("%B %Y")
@ -62,7 +62,11 @@ def make_calendar(today: datetime.date, tz: datetime.tzinfo):
output += "\n"
else:
output += " "
if print_day == today:
output += '<span foreground="blue">'
output += f"{print_day.day: >2}"
if print_day == today:
output += "</span>"
print_day += datetime.timedelta(days=1)
return output
@ -83,10 +87,14 @@ def main():
now = datetime.datetime.now(tz=tz)
text = now.strftime("%Y-%m-%d %H:%M")
tooltip = make_calendar(now.date(), tz)
tooltip = make_calendar(now.date())
out = Update(
text=text, alt="foo", tooltip=tooltip, css_class=["foo"], percentage="100"
text=text,
alt="foo",
tooltip=f"<tt>{tooltip}</tt>",
css_class=["foo"],
percentage="100",
)
print(out.dump(), flush=True)