waybar: add calendar with khal, fmt formatting
This commit is contained in:
parent
2f419e1760
commit
eaeed6ab5b
4 changed files with 81 additions and 26 deletions
37
bin/waybar_khal.py
Executable file
37
bin/waybar_khal.py
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import subprocess
|
||||||
|
import datetime
|
||||||
|
import json
|
||||||
|
from html import escape
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
today = datetime.date.today().strftime("%Y-%m-%d")
|
||||||
|
days = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Today",
|
||||||
|
"Tomorrow" ]
|
||||||
|
|
||||||
|
next_week = (datetime.date.today() + datetime.timedelta(days=10)).strftime("%Y-%m-%d")
|
||||||
|
|
||||||
|
output = subprocess.check_output("khal list --format \"{title}\" now "+next_week, shell=True)
|
||||||
|
output = output.decode("utf-8")
|
||||||
|
|
||||||
|
lines = output.split("\n")
|
||||||
|
new_lines = []
|
||||||
|
for line in lines:
|
||||||
|
clean_line = escape(line).split(" ::")[0]
|
||||||
|
# bold headers
|
||||||
|
if len(clean_line) and clean_line.split(",")[0] in days:
|
||||||
|
clean_line = f"\n<b>{clean_line}</b>"
|
||||||
|
new_lines.append(clean_line)
|
||||||
|
output = "\n".join(new_lines).strip()
|
||||||
|
|
||||||
|
today_text = datetime.date.today().strftime("%a, %d %b")
|
||||||
|
if today in output:
|
||||||
|
event = output.split('\n')[1]
|
||||||
|
data['text'] = f" {today_text}: {event}"
|
||||||
|
else:
|
||||||
|
data['text'] = f" {today_text}"
|
||||||
|
|
||||||
|
data['tooltip'] = output
|
||||||
|
|
||||||
|
print(json.dumps(data))
|
|
@ -30,6 +30,7 @@
|
||||||
"custom/separator#right",
|
"custom/separator#right",
|
||||||
"battery",
|
"battery",
|
||||||
"custom/separator#right",
|
"custom/separator#right",
|
||||||
|
"custom/calendar",
|
||||||
"clock",
|
"clock",
|
||||||
"tray"
|
"tray"
|
||||||
],
|
],
|
||||||
|
@ -39,6 +40,16 @@
|
||||||
"custom/separator#right": {
|
"custom/separator#right": {
|
||||||
"format": " <span foreground='#268bd2'>❮</span> "
|
"format": " <span foreground='#268bd2'>❮</span> "
|
||||||
},
|
},
|
||||||
|
"custom/calendar": {
|
||||||
|
"format": "{}",
|
||||||
|
"tooltip-format": "{}",
|
||||||
|
"tooltip": true,
|
||||||
|
"return-type": "json",
|
||||||
|
"interval": 300,
|
||||||
|
"escape": false,
|
||||||
|
"exec": "$HOME/.config/sway/bin/waybar_khal.py 2> /dev/null",
|
||||||
|
"on-click": "foot -T float khal interactive"
|
||||||
|
},
|
||||||
"custom/mail": {
|
"custom/mail": {
|
||||||
"format": "{icon} {}",
|
"format": "{icon} {}",
|
||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
|
@ -60,21 +71,19 @@
|
||||||
"format-icons": {
|
"format-icons": {
|
||||||
"chromium": " ",
|
"chromium": " ",
|
||||||
"firefox": " ",
|
"firefox": " ",
|
||||||
"Plexamp": "",
|
"Plexamp": " ",
|
||||||
"default": " "
|
"default": "♫ "
|
||||||
},
|
},
|
||||||
"escape": true,
|
"escape": true,
|
||||||
"exec": "$HOME/.config/sway/bin/waybar_mediaplayer.py 2> /dev/null",
|
"exec": "$HOME/.config/sway/bin/waybar_mediaplayer.py 2> /dev/null",
|
||||||
"exec-if": "pgrep plexamp"
|
"exec-if": "pgrep plexamp"
|
||||||
},
|
},
|
||||||
"clock": {
|
"clock": {
|
||||||
"format": "<span foreground='#ebdbb2'> </span>{:%a, %d %b <span foreground='#ebdbb2'> </span>%H:%M}",
|
"format": "<span foreground='#ebdbb2'> </span>{:%H:%M}",
|
||||||
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
|
|
||||||
"on-click": "foot -T float khal interactive"
|
"on-click": "foot -T float khal interactive"
|
||||||
|
|
||||||
},
|
},
|
||||||
"cpu": {
|
"cpu": {
|
||||||
"format": "<span foreground='#ebdbb2'></span> {usage}%",
|
"format": "<span foreground='#ebdbb2'></span> {usage:3}%",
|
||||||
"states": {
|
"states": {
|
||||||
"warning": 70,
|
"warning": 70,
|
||||||
"critical": 90
|
"critical": 90
|
||||||
|
@ -90,7 +99,7 @@
|
||||||
"on-click": "foot -T float bashtop"
|
"on-click": "foot -T float bashtop"
|
||||||
},
|
},
|
||||||
"backlight": {
|
"backlight": {
|
||||||
"format": "<span foreground='#ebdbb2'>{icon}</span> {percent}%",
|
"format": "<span foreground='#ebdbb2'>{icon}</span> {percent:3}%",
|
||||||
"format-icons": [""]
|
"format-icons": [""]
|
||||||
},
|
},
|
||||||
"battery": {
|
"battery": {
|
||||||
|
@ -100,15 +109,15 @@
|
||||||
"warning": 30,
|
"warning": 30,
|
||||||
"critical": 15
|
"critical": 15
|
||||||
},
|
},
|
||||||
"format": "<span foreground='#ebdbb2'>{icon}</span> {capacity}%",
|
"format": "<span foreground='#ebdbb2'>{icon}</span> {capacity:3}%",
|
||||||
"format-charging": "<span foreground='#268bd2'></span> {capacity}%",
|
"format-charging": "<span foreground='#268bd2'></span> {capacity:3}%",
|
||||||
"format-icons": ["", "", "", "", ""]
|
"format-icons": ["", "", "", "", ""]
|
||||||
},
|
},
|
||||||
"network#wl0": {
|
"network#wl0": {
|
||||||
"interval": 2,
|
"interval": 2,
|
||||||
"interface": "wl0",
|
"interface": "wl0",
|
||||||
"format": "{ifname}",
|
"format": "{ifname}",
|
||||||
"format-wifi": "<span foreground='#ebdbb2'> </span>{ifname} {essid} ({signalStrength}%)",
|
"format-wifi": "<span foreground='#ebdbb2'> </span>{ifname} {essid} ({signalStrength:3}%)",
|
||||||
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
||||||
|
@ -121,7 +130,7 @@
|
||||||
"interval": 2,
|
"interval": 2,
|
||||||
"interface": "en0",
|
"interface": "en0",
|
||||||
"format": "{ifname}",
|
"format": "{ifname}",
|
||||||
"format-wifi": "<span foreground='#ebdbb2'> </span> {essid} ({signalStrength}%)",
|
"format-wifi": "<span foreground='#ebdbb2'> </span> {essid} ({signalStrength:3}%)",
|
||||||
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
||||||
|
@ -134,7 +143,7 @@
|
||||||
"interval": 2,
|
"interval": 2,
|
||||||
"interface": "vpn0",
|
"interface": "vpn0",
|
||||||
"format": "{ifname}",
|
"format": "{ifname}",
|
||||||
"format-wifi": "<span foreground='#ebdbb2'> </span> {essid} ({signalStrength}%)",
|
"format-wifi": "<span foreground='#ebdbb2'> </span> {essid} ({signalStrength:3}%)",
|
||||||
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
"custom/separator#right",
|
"custom/separator#right",
|
||||||
"backlight",
|
"backlight",
|
||||||
"custom/separator#right",
|
"custom/separator#right",
|
||||||
|
"custom/calendar",
|
||||||
"clock",
|
"clock",
|
||||||
"tray"
|
"tray"
|
||||||
],
|
],
|
||||||
|
@ -36,6 +37,16 @@
|
||||||
"custom/separator#right": {
|
"custom/separator#right": {
|
||||||
"format": " <span foreground='#268bd2'>❮</span> "
|
"format": " <span foreground='#268bd2'>❮</span> "
|
||||||
},
|
},
|
||||||
|
"custom/calendar": {
|
||||||
|
"format": "{}",
|
||||||
|
"tooltip-format": "{}",
|
||||||
|
"tooltip": true,
|
||||||
|
"return-type": "json",
|
||||||
|
"interval": 300,
|
||||||
|
"escape": false,
|
||||||
|
"exec": "$HOME/.config/sway/bin/waybar_khal.py 2> /dev/null",
|
||||||
|
"on-click": "foot -T float khal interactive"
|
||||||
|
},
|
||||||
"custom/mail": {
|
"custom/mail": {
|
||||||
"format": "{icon} {}",
|
"format": "{icon} {}",
|
||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
|
@ -57,21 +68,19 @@
|
||||||
"format-icons": {
|
"format-icons": {
|
||||||
"chromium": " ",
|
"chromium": " ",
|
||||||
"firefox": " ",
|
"firefox": " ",
|
||||||
"Plexamp": "",
|
"Plexamp": " ",
|
||||||
"default": " "
|
"default": "♫ "
|
||||||
},
|
},
|
||||||
"escape": true,
|
"escape": true,
|
||||||
"exec": "$HOME/.config/sway/bin/waybar_mediaplayer.py 2> /dev/null",
|
"exec": "$HOME/.config/sway/bin/waybar_mediaplayer.py 2> /dev/null",
|
||||||
"exec-if": "pgrep plexamp"
|
"exec-if": "pgrep plexamp"
|
||||||
},
|
},
|
||||||
"clock": {
|
"clock": {
|
||||||
"format": "<span foreground='#ebdbb2'> </span>{:%a, %d %b <span foreground='#ebdbb2'> </span>%H:%M}",
|
"format": "<span foreground='#ebdbb2'> </span>{:%H:%M}",
|
||||||
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
|
|
||||||
"on-click": "foot -T float khal interactive"
|
"on-click": "foot -T float khal interactive"
|
||||||
|
|
||||||
},
|
},
|
||||||
"cpu": {
|
"cpu": {
|
||||||
"format": "<span foreground='#ebdbb2'></span> {usage}%",
|
"format": "<span foreground='#ebdbb2'></span> {usage:3}%",
|
||||||
"states": {
|
"states": {
|
||||||
"warning": 70,
|
"warning": 70,
|
||||||
"critical": 90
|
"critical": 90
|
||||||
|
@ -87,7 +96,7 @@
|
||||||
"on-click": "foot -T float bashtop"
|
"on-click": "foot -T float bashtop"
|
||||||
},
|
},
|
||||||
"backlight": {
|
"backlight": {
|
||||||
"format": "<span foreground='#ebdbb2'>{icon}</span> {percent}%",
|
"format": "<span foreground='#ebdbb2'>{icon}</span> {percent:3}%",
|
||||||
"format-icons": [""]
|
"format-icons": [""]
|
||||||
},
|
},
|
||||||
"battery": {
|
"battery": {
|
||||||
|
@ -97,15 +106,15 @@
|
||||||
"warning": 30,
|
"warning": 30,
|
||||||
"critical": 15
|
"critical": 15
|
||||||
},
|
},
|
||||||
"format": "<span foreground='#ebdbb2'>{icon}</span> {capacity}%",
|
"format": "<span foreground='#ebdbb2'>{icon}</span> {capacity:3}%",
|
||||||
"format-charging": "<span foreground='#268bd2'></span> {capacity}%",
|
"format-charging": "<span foreground='#268bd2'></span> {capacity:3}%",
|
||||||
"format-icons": ["", "", "", "", ""]
|
"format-icons": ["", "", "", "", ""]
|
||||||
},
|
},
|
||||||
"network#wl0": {
|
"network#wl0": {
|
||||||
"interval": 2,
|
"interval": 2,
|
||||||
"interface": "wl0",
|
"interface": "wl0",
|
||||||
"format": "{ifname}",
|
"format": "{ifname}",
|
||||||
"format-wifi": "<span foreground='#ebdbb2'> </span>{ifname} {essid} ({signalStrength}%)",
|
"format-wifi": "<span foreground='#ebdbb2'> </span>{ifname} {essid} ({signalStrength:3}%)",
|
||||||
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
||||||
|
@ -118,7 +127,7 @@
|
||||||
"interval": 2,
|
"interval": 2,
|
||||||
"interface": "en0",
|
"interface": "en0",
|
||||||
"format": "{ifname}",
|
"format": "{ifname}",
|
||||||
"format-wifi": "<span foreground='#ebdbb2'> </span> {essid} ({signalStrength}%)",
|
"format-wifi": "<span foreground='#ebdbb2'> </span> {essid} ({signalStrength:3}%)",
|
||||||
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
||||||
|
@ -131,7 +140,7 @@
|
||||||
"interval": 2,
|
"interval": 2,
|
||||||
"interface": "vpn0",
|
"interface": "vpn0",
|
||||||
"format": "{ifname}",
|
"format": "{ifname}",
|
||||||
"format-wifi": "<span foreground='#ebdbb2'> </span> {essid} ({signalStrength}%)",
|
"format-wifi": "<span foreground='#ebdbb2'> </span> {essid} ({signalStrength:3}%)",
|
||||||
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-ethernet": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
"format-linked": "<span foreground='#ebdbb2'> </span>{ifname}",
|
||||||
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
"format-disconnected": "<span foreground='#606060'></span>{ifname}",
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
* {
|
* {
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
font-family: Input, "Font Awesome 5 Free";
|
font-family: "Cascadia Code PL Regular";
|
||||||
font-size: 13px;
|
font-size: 12px;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue