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).
This commit is contained in:
Marty Oehme 2024-07-25 22:15:12 +02:00
parent 6905ce3ea7
commit 12d186d871
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 16 additions and 12 deletions

View file

@ -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 ]",

View file

@ -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))