From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43486-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 0d3806c4 for ; Tue, 18 Sep 2018 16:10:47 +0000 (UTC) Received: (qmail 28975 invoked by alias); 18 Sep 2018 16:10:36 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43486 Received: (qmail 14231 invoked by uid 1010); 18 Sep 2018 16:10:36 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-2.6/5.0):. Processed in 2.512444 secs); 18 Sep 2018 16:10:36 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=JtFlLg 5zzmPfLXUiYnQQryBPV9AvGziNalcAqoLLV68=; b=JgEOCskshlWy3y5illTmiz tgQUIyY8FLm8hNHJl4eeqMMVyx7hTddJM7qX9bS0/RKUi3qeh/AgxggSqRJvnqfE sdYaEGc3V9fTWSUGGouGOFetmB+XRtj5hBbfl3iglGp0S2tobQVRF8T7D4HcZK1j OcGzeponxXcfsUmUPcdv/yY0j+3gu6ND6bpf6JqLd5OYIPVHoGBKQANmzPJhnNhk fwDCFZdgqLuefKeMUM2y/+A91i2UGVHhNDkeqp4ZDHUfsdF7DmzFNxtsVWUa9ezh Toc4HVnJNcBNekHZ9RiYM9Yj5t5hFGWY4sZBBygd/hY+u5G+w4V/p93vwBP6wHuQ == DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=JtFlLg 5zzmPfLXUiYnQQryBPV9AvGziNalcAqoLLV68=; b=EEfslNCVGCM2rj9iG9YFMU XloLXl/8E3DUfScYntcETt2iwgfPk+bMW0L3zIazMwFhVOQ9Kt/i0L6cUTa3Kxd6 l4UE2jQYC9ktcgR9CK715WQ1z2YTeGMix01H8fpOIaNKA0w7WJ5t+PFM4/OOyy5b MnuZT6gtJRybRrl8J6dsUFZn3+O84uhwHdG8PGhCtWbTrlbQNMhP7ghmEr9gAXW/ 3oJt++t2Lftu/wlBZB5Ns5hSz1jqK3zNpLV0nS3BWGu1RYxMBQqhCAzJXL0omG/q /gGEdQjFy7ceDXr+1QnNv86XMPmbMV1fj0zzwC3WwF5F1z6fKQZuACfoqfC9AAlw == X-ME-Proxy: X-ME-Sender: Message-Id: <1537287030.1158541.1512325000.0C43F9DE@webmail.messagingengine.com> From: Daniel Shahaf To: Maximilian Bosch , zsh-workers@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-e556cd15 In-Reply-To: <20180918124951.4nbyjhbuqnkioqrt@hauptschuhle> References: <20180918124951.4nbyjhbuqnkioqrt@hauptschuhle> Date: Tue, 18 Sep 2018 16:10:30 +0000 Subject: Re: PATCH: search XDG_DATA_DIRS in _setxkbmap completion Maximilian Bosch wrote on Tue, 18 Sep 2018 14:49 +0200: > this patch searches in $XDG_DATA_DIRS for `/share/X11/xkb` > rather than using `/usr/lib` and `/usr/share`. > > This is helpful on distros such as NixOS which don't adopt the FHS[1][2]. > > [1] https://github.com/NixOS/nixpkgs/pull/46152#issuecomment-421755892 > [2] https://github.com/NixOS/nixpkgs/issues/46025 > > diff --git a/Completion/X/Command/_setxkbmap b/Completion/X/Command/_setxkbmap > index f7310ecdd..b3f8b1a46 100644 > --- a/Completion/X/Command/_setxkbmap > +++ b/Completion/X/Command/_setxkbmap > @@ -10,12 +10,18 @@ _setxkbmap() { > > # xkb files may be in different places depending on system > local dir sourcedir > - for dir in /usr/lib/X11/xkb /usr/share/X11/xkb; do > - if [ -d $dir ] ; then > - sourcedir=$dir > + setopt sh_word_split > + local IFS=: > + for dir in $XDG_DATA_DIRS; do > + fullName="$dir/X11/xkb" > + if [ -d $fullName ] ; then > + sourcedir=$fullName > break > fi > done > + unset IFS > + unsetopt sh_word_split > + Thanks for the patch. It's short, but there's a lot to say about it. 1. Shouldn't there be a fallback when $XDG_DATA_DIRS is unset? Such as the two hardcoded paths the patch is removing? Maybe also /usr/local equivalents of them. 2. Instead of setting + unsetting wordsplit and IFS it will be more idiomatic and more robust to do 'for dir in ${(s.:.)XDG_DATA_DIRS}'. 3. fullName should be made local (and not named in CamelCase). 4. ${XDG_DATA_HOME:-~/.local/share} should be examined too. How should empty array elements in XDG_DATA_DIRS be handled? E.g., XDG_DATA_DIRS=/foo:/bar::/baz ? It might be good to add a helper function that does the XDG_DATA_{DIRS,HOME} dance. It would be reusable and allow for extensibility. Cheers, Daniel > [ -d $sourcedir ] || return 1 > > local -a arguments > Email had 1 attachment: > + signature.asc > 1k (application/pgp-signature)