[PATCH app/setxkbmap 1/2] Add ~/.xkb to search path
Peter Hutterer
peter.hutterer at who-t.net
Tue Nov 22 03:10:45 UTC 2016
On Thu, Nov 17, 2016 at 10:42:38PM +0500, Mihail Konev wrote:
> Also look in $XDG_CONFIG_HOME/xkb, falling back to ~/.config/xkb
>
> Signed-off-by: Mihail Konev <k.mvc at ya.ru>
> ---
> configure.ac | 3 +++
> setxkbmap.c | 23 +++++++++++++++++++++++
> 2 files changed, 26 insertions(+)
>
> diff --git a/configure.ac b/configure.ac
> index 65a4ab6ea9b7..1cbded5e0af7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -33,6 +33,9 @@ AC_CONFIG_HEADERS([config.h])
> # Initialize Automake
> AM_INIT_AUTOMAKE([foreign dist-bzip2])
>
> +# Get _GNU_SOURCE and alike
> +AC_USE_SYSTEM_EXTENSIONS
> +
> # Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
> m4_ifndef([XORG_MACROS_VERSION],
> [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
> diff --git a/setxkbmap.c b/setxkbmap.c
> index cf0f02d6e704..7cac2ce5207c 100644
> --- a/setxkbmap.c
> +++ b/setxkbmap.c
> @@ -394,6 +394,29 @@ parseArgs(int argc, char **argv)
>
> ok = True;
> addToList(&inclPath, ".");
> + {
whenever something like this is needed that's a sign that you need a new
function. Please move this out.
> + const char *home = getenv("HOME");
> + const char *xdg = getenv("XDG_CONFIG_HOME");
> + char *home_path, *xdg_path;
> + int rc;
> +
> + rc = asprintf(&home_path, "%s/.xkb", home);
> + if (rc >= 0) {
> + addToList(&inclPath, home_path);
> + free(home_path);
> + }
this was removed again, right? please squash these together.
> +
> + rc = 0;
> + if (xdg != NULL) {
> + rc = asprintf(&xdg_path, "%s/xkb", xdg);
> + } else {
> + rc = asprintf(&xdg_path, "%s/.config/xkb", home);
> + }
please don't use {} for single-line statemetns
> + if (rc >= 0) {
> + addToList(&inclPath, xdg_path);
> + free(xdg_path);
you could use xdg_path[PATH_MAX] here to save on the cleanup work. might
make sense once you rebase and move the path generation into a helper
function (or might not :).
Cheers,
Peter
> + }
> + }
> addToList(&inclPath, DFLT_XKB_CONFIG_ROOT);
> for (i = 1; (i < argc) && ok; i++)
> {
> --
> 2.9.2
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list