2023-06-28 08:43:28 +02:00
|
|
|
#!/usr/bin/env python
|
2023-07-02 03:08:41 +02:00
|
|
|
|
2023-06-28 08:43:28 +02:00
|
|
|
import subprocess
|
2023-07-02 03:08:41 +02:00
|
|
|
import datetime
|
|
|
|
import json
|
|
|
|
from html import escape
|
|
|
|
|
2023-06-28 08:43:28 +02:00
|
|
|
data = {}
|
2023-07-02 03:08:41 +02:00
|
|
|
|
|
|
|
today = datetime.date.today().strftime("%Y-%m-%d")
|
|
|
|
|
|
|
|
next_week = (datetime.date.today() +
|
|
|
|
datetime.timedelta(days=10)).strftime("%Y-%m-%d")
|
|
|
|
|
2023-07-03 09:33:03 +02:00
|
|
|
output = subprocess.check_output("khal list now "+next_week, shell=True)
|
|
|
|
output = output.decode("utf-8")
|
2023-07-02 03:08:41 +02:00
|
|
|
|
2023-06-28 08:43:28 +02:00
|
|
|
lines = output.split("\n")
|
|
|
|
new_lines = []
|
|
|
|
for line in lines:
|
2023-07-03 09:33:03 +02:00
|
|
|
if len(line) and line[0].isalpha():
|
|
|
|
line = "\n<b>"+line+"</b>"
|
|
|
|
new_lines.append(line)
|
2023-06-28 08:43:28 +02:00
|
|
|
output = "\n".join(new_lines).strip()
|
2023-07-02 03:08:41 +02:00
|
|
|
|
|
|
|
if today in output:
|
2023-06-28 08:43:28 +02:00
|
|
|
data['text'] = " " + output.split('\n')[1]
|
|
|
|
else:
|
|
|
|
data['text'] = ""
|
2023-07-02 03:08:41 +02:00
|
|
|
|
2023-06-28 08:43:28 +02:00
|
|
|
data['tooltip'] = output
|
2023-07-02 03:08:41 +02:00
|
|
|
|
2023-06-28 08:43:28 +02:00
|
|
|
print(json.dumps(data))
|