Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: search XDG_DATA_DIRS in _setxkbmap completion



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: signature.asc
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author