[PATCH v2 app/setxkbmap] Add ~/.xkb and xdg dir to search path

k.mvc at ya.ru k.mvc at ya.ru
Sat Jul 8 15:47:22 UTC 2017


On Mon, Jun 26, 2017 at 01:36:44PM +1000, Peter Hutterer wrote:
> [off-list]
> 
> Hi Mihail,
> 
> First, sorry for dropping this, I wasn't cc'd on the patch and it
> disappeared into a black hole. Only dug this out today because the whole
> user-specific xkb configuration came up elsewhere and I had a vague
> recollection of it.
> 
> I have a question though on how you're currently using this whole thing:
> do you have a full install of xkeyboard-config in $XDG_CONFIG_HOME and just
> modify that with the custom keymap you have? Can you talk me through your
> setup and how the whole thing fits together? THanks
> 

Unfortunately, in now way. The patch was postponed, and then sent by
mistake (commit message totally missed idea of Todo:, making the change
look complete). The thread needs more work, just on the enabling the
dotdir, and is currently useless/unusable. At least:

- xkbcomp does not have `#include <>` or `#include_next`, only `#include ""`
- .xml descriptions need to be merged from dotdir and /usr
  (e.g. be read from both places)

Maybe it is not worth the hassle from UX standpoint - "stable" things
are in /usr, and "custom" are in ~/src ... - e.g. would anyone really
use this? The attempt was to ease/streamline installing of non-standard
keyboard layouts - "but is it really needed". Easy testing of xml?

(Although even if discarding the second point the first still should be
addressed.. one day..).

> Cheers,
>    Peter
> 
> On Tue, Nov 22, 2016 at 10:37:04AM +0500, Mihail Konev wrote:
> > Signed-off-by: Mihail Konev <k.mvc at ya.ru>
> > ---
> > Whichever directories get added, they should not differ from libxkbcommon
> > not to "break per-user installs" between setxkbmap and users of the latter :)
> > 
> >  setxkbmap.c | 36 ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 36 insertions(+)
> > 
> > diff --git a/setxkbmap.c b/setxkbmap.c
> > index cf0f02d6e704..42b8c3f04137 100644
> > --- a/setxkbmap.c
> > +++ b/setxkbmap.c
> > @@ -381,6 +381,40 @@ setOptString(int *arg, int argc, char **argv, setting_t *setting, enum source sr
> >  /***====================================================================***/
> >  
> >  /**
> > + * Retrieve name of ~/.config/xkb directory.
> > + */
> > +char *
> > +get_xdg_dir()
> > +{
> > +    static char path[PATH_MAX];
> > +
> > +    const char *home = getenv("HOME");

This should have really been using getpwnam ...

> > +    const char *xdg = getenv("XDG_CONFIG_HOME");
> > +    int rc;
> > +
> > +    if (xdg != NULL)
> > +        snprintf(path, sizeof path, "%s/xkb", xdg);
> > +    else
> > +        snprintf(path, sizeof path, "%s/.config/xkb", home);
> > +    return path;
> > +}
> > +/**
> > + * Retrieve name of ~/.xkb directory.
> > + */
> > +char *
> > +get_dot_dir()
> > +{
> > +    static char path[PATH_MAX];
> > +
> > +    const char *home = getenv("HOME");
> > +    snprintf(path, sizeof path, "%s/.config/xkb", home);
> > +    return path;
> > +}
> > +
> > +
> > +/***====================================================================***/
> > +
> > +/**
> >   * Parse commandline arguments.
> >   * Return True on success or False if an unrecognized option has been
> >   * specified.
> > @@ -394,6 +428,8 @@ parseArgs(int argc, char **argv)
> >  
> >      ok = True;
> >      addToList(&inclPath, ".");
> > +    addToList(&inclPath, get_xdg_dir());
> > +    addToList(&inclPath, get_dot_dir());
> >      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
> > 

"Some delay".
Mihail


More information about the xorg-devel mailing list