mirror of
https://git.pumpin.online/funkpower/menologion.git
synced 2026-10-23 03:07:12 +00:00
the documented way to use this did not work
`import qs.horologion.modules` was the README's headline instruction and it
fails outright: Quickshell resolves `qs` against the host config root, not
the subtree, so in an empty shell the type is unavailable and in a populated
one the widget would have silently bound to the host's Config and Theme
instead of its own. The imports inside are now relative and each directory
carries a qmldir, so `import "horologion/modules"` works in any host and the
three pieces really are usable on their own.
- refresh() dropped a request made while a run was in flight, so a
jurisdiction or date set a moment after startup never took effect until
midnight. It queues now.
- The waybar script exited non-zero on its error paths, and waybar hides a
module whose script does that -- so a missing typikon made the module
vanish rather than say so, and the .error CSS was dead. An unrecognised
--format field raised instead of rendering empty, and the tooltip
interpolated unescaped text into Pango markup, which matters because
--update-menaion fetches commemorations from a page nobody here controls.
- The installer aborted the whole run at the point where it printed
'leaving it alone', and a wholly successful run exited 1 because the last
statement was a failed [ -d ] test under set -e. --help demanded typikon,
which is what --help would have told you to install.
- eww painted every day with the feast colour and printed a dangling
separator, because it compares against "" and eww renders a JSON null as
the string "null". The parenthesised ?: form two lines away was already
right. The week list also repeated today.
pip install typikon installed nothing; there is no such package, and that was
the first line of every install path. Pascha now carries its label instead of
being a bare ISO date in a corner.
tests/smoke.sh covers the scripts, which is where all of this lived and where
nothing was covered. It caught two of these while being written.
This commit is contained in:
+24
-6
@@ -14,6 +14,8 @@ particular law actually binds.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import html
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -41,26 +43,42 @@ def main():
|
||||
try:
|
||||
days = run(args.jurisdiction, args.days)
|
||||
except FileNotFoundError:
|
||||
# Exit 0 on purpose, here and below: waybar hides a custom module whose
|
||||
# script exits non-zero, so a non-zero exit would make the module
|
||||
# vanish instead of showing why it could not answer.
|
||||
print(json.dumps({"text": "typikon?", "tooltip":
|
||||
"typikon is not on PATH", "class": "error"}))
|
||||
return 1
|
||||
return 0
|
||||
except (subprocess.CalledProcessError, ValueError) as exc:
|
||||
print(json.dumps({"text": "⚠", "tooltip": str(exc), "class": "error"}))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
today = days[0]
|
||||
fields = dict(today)
|
||||
# `or ""` would blank a legitimate 0, so only None and missing become "".
|
||||
fields = {k: ("" if v is None else v) for k, v in today.items()}
|
||||
if args.no_emoji:
|
||||
fields["emoji"] = ""
|
||||
text = args.format.format(**{k: fields.get(k) or "" for k in fields}).strip()
|
||||
try:
|
||||
# format_map over a defaultdict: a field name that does not exist comes
|
||||
# out empty rather than raising, because the --help text advertises
|
||||
# eight names and someone will always try a ninth.
|
||||
text = args.format.format_map(collections.defaultdict(str, fields)).strip()
|
||||
except (IndexError, ValueError) as exc:
|
||||
print(json.dumps({"text": "\u26a0", "class": "error",
|
||||
"tooltip": f"bad --format: {exc}"}))
|
||||
return 0
|
||||
|
||||
tip = []
|
||||
head = today["title"]
|
||||
if today.get("churchDate") and today["churchDate"] not in head:
|
||||
head += f" ({today['churchDate']})"
|
||||
tip.append(f"<b>{head}</b>")
|
||||
# waybar renders the tooltip as Pango markup, so anything interpolated into
|
||||
# it has to be escaped. Nothing in the shipped data contains an ampersand,
|
||||
# but `typikon --update-menaion` fetches commemorations from a third-party
|
||||
# page, and that is exactly where one arrives.
|
||||
tip.append(f"<b>{html.escape(head)}</b>")
|
||||
if today.get("cycle"):
|
||||
tip.append(f"<i>{today['cycle']}</i>")
|
||||
tip.append(f"<i>{html.escape(today['cycle'])}</i>")
|
||||
tip.append("")
|
||||
line = today["fastLabel"]
|
||||
if today.get("obligation") == "obligatory":
|
||||
|
||||
Reference in New Issue
Block a user