From e82bf23c08c4e9530124b3eafd0fd8a1eefec9c7 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Wed, 13 Apr 2022 11:54:11 +0200 Subject: [PATCH] sway/waybar: Make calendar work with special chars The implementation is not very pretty, but this is a limitation of the chosen design (parsing the output of a cli tool). --- users/simon/modules/sway/waybar.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/users/simon/modules/sway/waybar.nix b/users/simon/modules/sway/waybar.nix index 10f8e27..17aa46a 100644 --- a/users/simon/modules/sway/waybar.nix +++ b/users/simon/modules/sway/waybar.nix @@ -223,6 +223,7 @@ in interval = 300; exec = pkgs.writeScript "calendar" /* python */ '' #!${pkgs.python3}/bin/python3 + import html import json import subprocess @@ -234,7 +235,21 @@ in events_today = khal(["list", "today", "today", "-df", "", "-f", "{title}"]).rstrip().split("\n") - events_2d = khal(["list", "today", "tomorrow", "-df", "{name}, {date}"]).rstrip() + events_2d = ( + html.escape( + khal( + [ + "list", + "today", + "tomorrow", + "-df", + "WAYBARSTARTKHAL{name}, {date}WAYBARENDKHAL", + ] + ).rstrip() + ) + .replace("WAYBARSTARTKHAL", "") + .replace("WAYBARENDKHAL", "") + ) if len(events_today) == 1 and events_today[0] == "No events": events_today = []