From 6905ce3ea78ab1d65942fb60bd95adc186373f38 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 25 Jul 2024 22:01:50 +0200 Subject: [PATCH] waybar: Change calendar block whitespace When there are no new calendar events for the current day we do not display any whitespace after the icon. --- desktop/.config/waybar/modules/khal.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/desktop/.config/waybar/modules/khal.py b/desktop/.config/waybar/modules/khal.py index ba96199..8cff47d 100755 --- a/desktop/.config/waybar/modules/khal.py +++ b/desktop/.config/waybar/modules/khal.py @@ -1,10 +1,14 @@ #!/usr/bin/env python # from https://gist.github.com/bjesus/178a9bd3453470d74803945dbbf9ed40 # List upcoming khal events in simple json container fit for waybar +# +# Hovering over the item displays all upcoming +# The icon changes if there are events today, and displays the +# closest upcoming one. -import subprocess import datetime import json +import subprocess from html import escape data = {} @@ -17,10 +21,10 @@ output = subprocess.check_output("khal list now " + next_week, shell=True) output = output.decode("utf-8") lines = output.split("\n") -new_lines = [] +new_lines: list[str] = [] for line in lines: clean_line = escape(line).split(" ::")[0] - if len(clean_line) and not clean_line[0] in ["0", "1", "2"]: + if len(clean_line) and clean_line[0] not in ["0", "1", "2"]: clean_line = "\n" + clean_line + "" new_lines.append(clean_line) output = "\n".join(new_lines).strip() @@ -28,7 +32,7 @@ output = "\n".join(new_lines).strip() if today in output: data["text"] = " " + output.split("\n")[1] else: - data["text"] = " " + data["text"] = "" data["tooltip"] = output