diff options
| author | user <user@clank> | 2026-09-22 12:57:26 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-22 12:57:26 +0200 |
| commit | 68ff62e9492accd4c1c9a83edbcbd225afb1a11a (patch) | |
| tree | b744ad33cdbaa25fca333f28f13b5e7df28838dd /include | |
| parent | themes: a picker that wears them as you browse (C-a t) (diff) | |
| download | slosh-68ff62e9492accd4c1c9a83edbcbd225afb1a11a.tar.gz slosh-68ff62e9492accd4c1c9a83edbcbd225afb1a11a.tar.xz slosh-68ff62e9492accd4c1c9a83edbcbd225afb1a11a.zip | |
themes: ask the binary where it is, not the prefix it was built for
`theme_name "sl0p"` with all seven themes sitting in /usr/share/slosh/themes:
"no theme named sl0p". The lookup knew two places -- your own themes directory
and the PREFIX this build was compiled with -- and on that machine the first
did not exist and the second was /usr/local, because that is the Makefile's
default and the package was built with PREFIX=/usr. Neither was where the
themes actually were, and nothing in the search could ever have found them.
A compiled-in prefix is a guess about where the binary will end up, and the
binary is the one thing that knows where it really is. So the search now asks
it: path_self() (/proc/self/exe, _NSGetExecutablePath, GetModuleFileName --
lifted out of server.c, which was already doing this for SLOSH_BIN) gives
<bin>/../share/slosh/themes for an installed slosh wherever it was installed
to, and <repo>/contrib/themes for one being run out of a build tree, which
makes a checkout able to name a theme without installing anything first. The
compiled-in prefix stays as the last candidate, for a binary sitting somewhere
that says nothing about its data, and duplicates collapse so the usual install
does not report the same directory twice.
Your own directory is still first and still shadows everything, which is the
property that matters; the rest is about the shipped set being findable at all.
The tests that assumed a closed world of two temp themes now narrow to their
own names by typing, since the shipped ones are (correctly) always in the list
-- and the "no themes anywhere" toast lost its test, because with the shipped
set reachable that state takes a binary with nothing beside it. The case that
started this is a test of its own.
Diffstat (limited to 'include')
| -rw-r--r-- | include/app.h | 3 | ||||
| -rw-r--r-- | include/config.h | 4 | ||||
| -rw-r--r-- | include/slosh.h | 3 |
3 files changed, 9 insertions, 1 deletions
diff --git a/include/app.h b/include/app.h index 74b841d..3a660b2 100644 --- a/include/app.h +++ b/include/app.h @@ -5,6 +5,7 @@ #ifndef SLOSH_APP_H #define SLOSH_APP_H +#include "config.h" #include "graphics.h" #include "kdl.h" #include "project.h" @@ -74,7 +75,7 @@ bool app_set_theme(const char *name, bool save, char *err, size_t errcap); const char *app_theme(void); /* What there is to pick from, and where it was looked for. Through the app * rather than the config, because the front ends do not own a config. */ -size_t app_themes(char (*out)[64], size_t max); +size_t app_themes(char (*out)[THEME_NAME_MAX], size_t max); size_t app_theme_dirs(char (*out)[512], size_t max); /* The files the config in force was read from: the one that was loaded and * everything it included, existing or not. What the watcher watches. */ diff --git a/include/config.h b/include/config.h index d3c7e55..25fcc41 100644 --- a/include/config.h +++ b/include/config.h @@ -153,6 +153,10 @@ enum { #define THEMES_MAX 64 #define THEME_NAME_MAX 64 +/* How many directories a theme is looked for in: yours, two derived from + * where the binary is, and the prefix this build was compiled with. */ +#define THEME_DIRS_MAX 4 + typedef struct { /* geometry */ uint16_t gap, gap_aspect; diff --git a/include/slosh.h b/include/slosh.h index 8f96543..beec697 100644 --- a/include/slosh.h +++ b/include/slosh.h @@ -137,6 +137,9 @@ const char *path_base(const char *path); const char *path_relative(const char *path, const char *base); /* mkdir -p, for the directory a config or a session socket wants to live in. */ bool path_mkdirs(const char *dir); +/* This binary's own path, from the kernel rather than from argv[0]. What lets + * slosh find the files installed beside it without being told where they are. */ +bool path_self(char *out, size_t cap); /* ---- the shell a pane gets when nothing else is said -------------------- */ |
