diff options
| author | user <user@clank> | 2026-08-15 23:21:40 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-15 23:21:40 +0200 |
| commit | b9ae6cbcbce3816c2b2e8f760f082d3eaa3b5184 (patch) | |
| tree | 8dd1f16ac15edd16f51ba07e37c312ccb89f53f1 /src/server.c | |
| parent | sl0ppty: watch what the config was built from, not just what it was called (diff) | |
| download | slosh-b9ae6cbcbce3816c2b2e8f760f082d3eaa3b5184.tar.gz slosh-b9ae6cbcbce3816c2b2e8f760f082d3eaa3b5184.tar.xz slosh-b9ae6cbcbce3816c2b2e8f760f082d3eaa3b5184.zip | |
sl0ppty: say what the config could not honour
A config that half-applied said nothing. An unknown shader, a binding
that does not parse, an include that is not there: the file loaded, that
line did not, and the session announced "config reloaded" as though
nothing had happened. Every one of those messages was already being
produced -- config_load has filled `err` on a successful load since it
was written -- and then dropped on the floor by every caller, because a
non-zero return meant "fine".
So the complaint from the last load is kept, and the front end says it
where it would have said "config reloaded". Once at startup too: a config
that loaded with a complaint still started the session, and the stderr
line goes where nobody attached can read it. The `reload` control verb
answers `{"ok":true,"warning":"..."}` -- ok, because the file did apply,
with the reason attached for a script that cares.
Two things fell out of writing the test for it.
An include's complaint was reported by nobody when the file in the middle
was fine. apply_includes only looked at the return value, so a theme that
loaded while *its* include was missing swallowed the message: the child
returned true, and true meant there was nothing to say. The complaint now
travels up whether or not the include itself loaded.
And a complaint now carries the name of the file it happened in, exactly
once -- added by the file that produced it, never by the files that
included it, because prefixing at every level builds a chain that
truncates before the part that matters. So:
t.kdl: unknown shader: bloom
keys.kdl: line 2: unknown action fly
b.kdl: includes nested too deep (a cycle?)
cannot open /home/you/.config/sl0ppty/themes/nope.kdl
which is enough to know which file to open, in a message that fits in a
toast.
Diffstat (limited to 'src/server.c')
| -rw-r--r-- | src/server.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/server.c b/src/server.c index 0420ffe..59b3c9c 100644 --- a/src/server.c +++ b/src/server.c @@ -275,6 +275,14 @@ int server_run(const char *name, const char *const argv[], uint16_t cols, app_compose(s.app, &s.screen); /* a click resolves against a painted frame */ + /* A config that loaded with a complaint in it still started the session, so + * the complaint has nowhere to go but here. Once, at startup: the log line is + * written where nobody attached will see it. */ + { + const char *why = app_config_complaint(); + if (why && *why) app_toast(s.app, why); + } + /* Watch the config's *directory*, not the file. Editors overwhelmingly save * by writing a temporary file and renaming it over the target, which swaps * the inode out from under a watch on the file itself: it fires once and @@ -477,7 +485,11 @@ int server_run(const char *name, const char *const argv[], uint16_t cols, /* The set of files can have changed with the config that named them: * an include added, pointed somewhere else, or taken out. */ watch_config(&watches); - app_toast(s.app, "config reloaded"); + /* A complaint rather than "config reloaded": the file applied, and one + * line of it did not. Saying only the good half is how a mistyped + * include becomes ten minutes of wondering. */ + const char *why = app_config_complaint(); + app_toast(s.app, why && *why ? why : "config reloaded"); } else { app_toast(s.app, err[0] ? err : "config reload failed"); } |
