diff --git a/bin/waybar_khal.py b/bin/waybar_khal.py
index 089e4e3..ce45b77 100755
--- a/bin/waybar_khal.py
+++ b/bin/waybar_khal.py
@@ -12,26 +12,40 @@ days = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Su
next_week = (datetime.date.today() + datetime.timedelta(days=10)).strftime("%Y-%m-%d")
-output = subprocess.check_output("khal list --format \"{title}\" now "+next_week, shell=True)
-output = output.decode("utf-8")
+title = subprocess.check_output("khal list --format \"{title}\" now "+next_week,
+ shell=True).decode("UTF-8").split("\n")
+start = subprocess.check_output("khal list --format \"{start}\" now "+next_week,
+ shell=True).decode("UTF-8").split("\n")
+end = subprocess.check_output("khal list --format \"{end}\" now "+next_week,
+ shell=True).decode("UTF-8").split("\n")
-lines = output.split("\n")
-new_lines = []
-for line in lines:
- clean_line = escape(line).split(" ::")[0]
- # bold headers
- if len(clean_line) and clean_line.split(",")[0] in days:
- clean_line = f"\n{clean_line}"
- new_lines.append(clean_line)
-output = "\n".join(new_lines).strip()
+lines = ""
+for i in range(len(title)):
+ t = escape(title[i])
+ s = escape(start[i])
+ e = escape(end[i])
+ line = ""
+ if len(t) and t.split(",")[0] in days:
+ line = f"\n{t}"
+ else:
+ ss = s.split(" ")
+ es = e.split(" ")
+ if len(es) == 1 or len(ss) == 1:
+ line = f"{t}"
+ else:
+ line = f"{ss[1]} - {es[1]}: {t}"
-today_text = datetime.date.today().strftime("%a, %d %b")
-if today in output:
- event = output.split('\n')[1]
- data['text'] = f" {today_text}: {event}"
+ lines += f"{line}\n"
+
+if today in lines:
+ event = lines.split('\n')[2]
+ if len(event) > 30:
+ event = f"{event[0:30]}…"
+ data["text"] = f"{event}"
+ data["alt"] = "event"
else:
- data['text'] = f" {today_text}"
-
-data['tooltip'] = output
+ data["text"] = "-"
+ data["alt"] = "idle"
+data["tooltip"] = lines
print(json.dumps(data))
diff --git a/waybar.d/config b/waybar.d/config
index c6318f7..4855bae 100644
--- a/waybar.d/config
+++ b/waybar.d/config
@@ -41,11 +41,15 @@
"format": " ❮ "
},
"custom/calendar": {
- "format": "{}",
+ "format": "{icon} {}",
"tooltip-format": "{}",
"tooltip": true,
"return-type": "json",
"interval": 300,
+ "format-icons": {
+ "event": " ",
+ "idle": " "
+ },
"escape": false,
"exec": "$HOME/.config/sway/bin/waybar_khal.py 2> /dev/null",
"on-click": "foot -T float khal interactive"
@@ -79,7 +83,7 @@
"exec-if": "pgrep plexamp"
},
"clock": {
- "format": " {:%H:%M}",
+ "format": " {: %a, %b %d, %H:%M}",
"on-click": "foot -T float khal interactive"
},
"cpu": {