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).
pull/64/head
Simon Bruder 2022-04-13 11:54:11 +02:00
parent af4da03c50
commit e82bf23c08
Signed by: simon
GPG Key ID: 8D3C82F9F309F8EC
1 changed files with 16 additions and 1 deletions

View File

@ -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", "<b>{name}, {date}</b>"]).rstrip()
events_2d = (
html.escape(
khal(
[
"list",
"today",
"tomorrow",
"-df",
"WAYBARSTARTKHAL{name}, {date}WAYBARENDKHAL",
]
).rstrip()
)
.replace("WAYBARSTARTKHAL", "<b>")
.replace("WAYBARENDKHAL", "</b>")
)
if len(events_today) == 1 and events_today[0] == "No events":
events_today = []