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).
This commit is contained in:
parent
af4da03c50
commit
e82bf23c08
|
@ -223,6 +223,7 @@ in
|
||||||
interval = 300;
|
interval = 300;
|
||||||
exec = pkgs.writeScript "calendar" /* python */ ''
|
exec = pkgs.writeScript "calendar" /* python */ ''
|
||||||
#!${pkgs.python3}/bin/python3
|
#!${pkgs.python3}/bin/python3
|
||||||
|
import html
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
@ -234,7 +235,21 @@ in
|
||||||
|
|
||||||
|
|
||||||
events_today = khal(["list", "today", "today", "-df", "", "-f", "{title}"]).rstrip().split("\n")
|
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":
|
if len(events_today) == 1 and events_today[0] == "No events":
|
||||||
events_today = []
|
events_today = []
|
||||||
|
|
Loading…
Reference in a new issue