mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 20:30:27 +01:00
quirks: add XDG_RUNTIME_DIR/libinput to the quirks directories
This allows tools like libinput-replay and the test suite to install temporary quirks without having to mess with actual system-installed files or directories. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1297>
This commit is contained in:
parent
4e002383cf
commit
ce87da63ba
1 changed files with 16 additions and 2 deletions
18
src/quirks.c
18
src/quirks.c
|
|
@ -1208,7 +1208,9 @@ is_data_file(const struct dirent *dir)
|
|||
}
|
||||
|
||||
static inline bool
|
||||
parse_files(struct quirks_context *ctx, const char *data_path)
|
||||
parse_files(struct quirks_context *ctx,
|
||||
const char *data_path,
|
||||
bool allow_empty_directory)
|
||||
{
|
||||
struct dirent **namelist;
|
||||
int ndev = -1;
|
||||
|
|
@ -1216,6 +1218,9 @@ parse_files(struct quirks_context *ctx, const char *data_path)
|
|||
|
||||
ndev = scandir(data_path, &namelist, is_data_file, versionsort);
|
||||
if (ndev <= 0) {
|
||||
if (allow_empty_directory)
|
||||
return true;
|
||||
|
||||
qlog_error(ctx, "%s: failed to find data files\n", data_path);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1261,12 +1266,21 @@ quirks_init_subsystem(const char *data_path,
|
|||
if (!ctx->dmi && !ctx->dt)
|
||||
return NULL;
|
||||
|
||||
if (!parse_files(ctx, data_path))
|
||||
if (!parse_files(ctx, data_path, false))
|
||||
return NULL;
|
||||
|
||||
if (override_file && !parse_file(ctx, override_file))
|
||||
return NULL;
|
||||
|
||||
_autofree_ char *xdg_runtime_dir = safe_strdup(getenv("XDG_RUNTIME_DIR"));
|
||||
if (!xdg_runtime_dir)
|
||||
xdg_runtime_dir = strdup_printf("/run/user/%d", geteuid());
|
||||
|
||||
_autofree_ char *xdg_runtime_quirks_dir =
|
||||
strdup_printf("%s/libinput/", xdg_runtime_dir);
|
||||
if (!parse_files(ctx, xdg_runtime_quirks_dir, true))
|
||||
return NULL;
|
||||
|
||||
return steal(&ctx);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue