zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: search XDG_DATA_DIRS in _setxkbmap completion
@ 2018-09-18 12:49 Maximilian Bosch
  2018-09-18 16:10 ` Daniel Shahaf
  0 siblings, 1 reply; 9+ messages in thread
From: Maximilian Bosch @ 2018-09-18 12:49 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]

Hi,

this patch searches in $XDG_DATA_DIRS for `<XDG_DATA_DIR>/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].

Maximilian

[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
+
     [ -d $sourcedir ] || return 1
 
     local -a arguments

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: PATCH: search XDG_DATA_DIRS in _setxkbmap completion
@ 2018-09-19  4:53 TS
  2018-09-19 14:29 ` Daniel Shahaf
  0 siblings, 1 reply; 9+ messages in thread
From: TS @ 2018-09-19  4:53 UTC (permalink / raw)
  To: Zsh hackers list

Hello

> How should empty array elements in XDG_DATA_DIRS be handled?  E.g.,
> XDG_DATA_DIRS=/foo:/bar::/baz ?

how about s.th. around the lines of:

tosh ~ %
XDG_DATA_DIRS=/usr/lib/X11/xkb:/usr/share/X11/xkb:/usr/local/lib/X11/xkb:/usr/local/share/X11/xkb
tosh ~ % typeset -aU searchdirs
tosh ~ % searchdirs=(${(s.:.)XDG_DATA_DIRS}
{/usr/lib,/usr/share,/usr/local/lib,/usr/local/share}/X11/xkb ${XDG_DATA_HOME}
~/.local/share/X11/xkb)
tosh ~ % ev searchdirs
array-unique  searchdirs:
1='/usr/lib/X11/xkb'
2='/usr/share/X11/xkb'
3='/usr/local/lib/X11/xkb'
4='/usr/local/share/X11/xkb'
5='/home/heinb/.local/share/X11/xkb'
tosh ~ % searchdirs+=('')      << just for example
tosh ~ % ev searchdirs
array-unique  searchdirs:
1='/usr/lib/X11/xkb'
2='/usr/share/X11/xkb'
3='/usr/local/lib/X11/xkb'
4='/usr/local/share/X11/xkb'
5='/home/heinb/.local/share/X11/xkb'
6=''                          <<------ empty
tosh ~ % searchdirs=(${^~searchdirs}(N/))
tosh ~ % ev searchdirs
array-unique  searchdirs:
1='/usr/share/X11/xkb'




kind regards,

     Thilo

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-09-19 21:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-18 12:49 PATCH: search XDG_DATA_DIRS in _setxkbmap completion Maximilian Bosch
2018-09-18 16:10 ` Daniel Shahaf
2018-09-18 19:05   ` Maximilian Bosch
2018-09-18 19:32     ` Daniel Shahaf
2018-09-19 20:36       ` Maximilian Bosch
2018-09-19 21:30         ` Daniel Shahaf
2018-09-19  4:53 TS
2018-09-19 14:29 ` Daniel Shahaf
2018-09-19 19:53   ` TS

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).