From 12d186d871857180bcb2df415118c1912bd22759 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 25 Jul 2024 22:15:12 +0200 Subject: [PATCH] waybar: Improve events block icon rendering Using the 'alt' json return field to set the icon and change the icon within waybar itself instead of doing so manually in the script. This makes us a little more flexible and puts all the 'what' is rendered that is specific to waybar into waybar (keeping the 'how' it's rendered in the style.css). --- desktop/.config/waybar/config | 18 +++++++++++------- desktop/.config/waybar/modules/khal.py | 10 +++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/desktop/.config/waybar/config b/desktop/.config/waybar/config index 81d4e74..e0d7ca1 100644 --- a/desktop/.config/waybar/config +++ b/desktop/.config/waybar/config @@ -49,12 +49,16 @@ "on-click-right": "$TERMINAL start --class float glances" }, "custom/events": { - "format": "{}", - "interval": 300, - "exec": "~/.config/waybar/modules/khal.py 2>/dev/null", "exec-if": "command -v khal >/dev/null 2>&1", + "exec": "~/.config/waybar/modules/khal.py 2>/dev/null", "return-type": "json", - "on-click": "$TERMINAL start --class float ikhal" + "interval": 300, + "on-click": "$TERMINAL start --class float ikhal", + "format": "{icon}{}", + "format-icons": { + "event": " ", + "no-event": "", + }, }, "memory": { "interval": 30, @@ -138,7 +142,7 @@ "tag-labels": [ "", "", "", "", "", "", "", "", "", "" ] }, "river/mode": { - "format": "{} 󱐁", + "format": "{} ", }, "river/window": { "format": " {}", @@ -172,10 +176,10 @@ "interval": 60, }, "custom/vidl": { - "format": "{} {icon}", + "format": "{icon}{}", "format-alt-click": "right", "format-icons": { - "default": "" + "default": " " }, "exec": "wc -l ~/.local/share/vidl/vidl_queue | cut -d' ' -f1", "exec-if": "[ -f ~/.local/share/vidl/vidl_queue ]", diff --git a/desktop/.config/waybar/modules/khal.py b/desktop/.config/waybar/modules/khal.py index 8cff47d..6dc3971 100755 --- a/desktop/.config/waybar/modules/khal.py +++ b/desktop/.config/waybar/modules/khal.py @@ -29,11 +29,11 @@ for line in lines: new_lines.append(clean_line) output = "\n".join(new_lines).strip() -if today in output: - data["text"] = " " + output.split("\n")[1] -else: - data["text"] = "" - +data["alt"] = "no-event" data["tooltip"] = output +if today in output: + data["text"] = output.split("\n")[1] + data["alt"] = "event" + print(json.dumps(data))