diff --git a/ansible/roles/sway/files/waybar_config.json b/ansible/roles/sway/files/waybar_config.json index 1b3d667..4d13bc9 100644 --- a/ansible/roles/sway/files/waybar_config.json +++ b/ansible/roles/sway/files/waybar_config.json @@ -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 } diff --git a/ansible/roles/sway/files/waybar_custom_clock.py b/ansible/roles/sway/files/waybar_custom_clock.py index 6a2fe35..a8d499d 100644 --- a/ansible/roles/sway/files/waybar_custom_clock.py +++ b/ansible/roles/sway/files/waybar_custom_clock.py @@ -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 += '' output += f"{print_day.day: >2}" + if print_day == today: + output += "" 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"{tooltip}", + css_class=["foo"], + percentage="100", ) print(out.dump(), flush=True)