From ea066eebb5d16dc0b0c81fa741e516d292e1be1c Mon Sep 17 00:00:00 2001
From: Marty Oehme <contact@martyoeh.me>
Date: Sat, 8 Mar 2025 08:41:53 +0100
Subject: [PATCH] waybar: Fix event module spacing

Added a new state which should fix the icon spacing issues:

When we have no upcoming events or upcoming events but none today, we
only display the icon and so we do not add any additional spacing.
(This is alt state `event` or `no-event`)

Only if we have an upcoming event today (alt state `event-today`) are we
printing it directly on the status bar and only then should be have
additional spacing. So we have an icon (the same as for event) with the
correct spacing so that whether there is text on the statusbar or not,
we space correctly.
---
 desktop/.config/waybar/config          |  1 +
 desktop/.config/waybar/modules/khal.py | 11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/desktop/.config/waybar/config b/desktop/.config/waybar/config
index 0d72df1..8b3dcf2 100644
--- a/desktop/.config/waybar/config
+++ b/desktop/.config/waybar/config
@@ -64,6 +64,7 @@
         "format": "{icon}{0}", // issue tracked here https://github.com/Alexays/Waybar/issues/3623
         "format-icons": {
             "event": "",
+            "event-today": "  ",
             "no-event": "",
         },
     },
diff --git a/desktop/.config/waybar/modules/khal.py b/desktop/.config/waybar/modules/khal.py
index 6dc3971..76f4280 100755
--- a/desktop/.config/waybar/modules/khal.py
+++ b/desktop/.config/waybar/modules/khal.py
@@ -27,13 +27,16 @@ for line in lines:
     if len(clean_line) and clean_line[0] not in ["0", "1", "2"]:
         clean_line = "\n<b>" + clean_line + "</b>"
     new_lines.append(clean_line)
+
 output = "\n".join(new_lines).strip()
 
-data["alt"] = "no-event"
-data["tooltip"] = output
-
-if today in output:
+if today in output: # an event today!
+    data["alt"] = "event-today"
     data["text"] = output.split("\n")[1]
+elif output: # an event in the week!
     data["alt"] = "event"
+    data["tooltip"] = output
+else: # no events
+    data["alt"] = "no-event"
 
 print(json.dumps(data))