wayland: Consolidate with mako into desktop module
Since the existing wayland module basically describes everything about my 'desktop environment' setup already anyway, might as well rename it accordingly. Additionally, mako is important for notifications in this environment so it moves here as well.
This commit is contained in:
parent
4c33a6da56
commit
2e0c992a54
12 changed files with 10 additions and 2 deletions
35
desktop/.config/waybar/modules/khal.py
Executable file
35
desktop/.config/waybar/modules/khal.py
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python
|
||||
# from https://gist.github.com/bjesus/178a9bd3453470d74803945dbbf9ed40
|
||||
# List upcoming khal events in simple json container fit for waybar
|
||||
|
||||
import subprocess
|
||||
import datetime
|
||||
import json
|
||||
from html import escape
|
||||
|
||||
data = {}
|
||||
|
||||
today = datetime.date.today().strftime("%Y-%m-%d")
|
||||
|
||||
next_week = (datetime.date.today() + datetime.timedelta(days=10)).strftime("%Y-%m-%d")
|
||||
|
||||
output = subprocess.check_output("khal list 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]
|
||||
if len(clean_line) and not clean_line[0] in ["0", "1", "2"]:
|
||||
clean_line = "\n<b>" + clean_line + "</b>"
|
||||
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["tooltip"] = output
|
||||
|
||||
print(json.dumps(data))
|
||||
Loading…
Add table
Add a link
Reference in a new issue