xdg-wrappers: add mbsync, make wrappers use next-in-path

The new next-in-path utility function finds the next entry for the
wrapped name in PATH after the called script, instead of hardcoding the
usual location for a system install.
This commit is contained in:
Alexander Gehrke 2021-11-15 12:52:52 +01:00
parent 761b7700ab
commit e43c38c529
4 changed files with 19 additions and 0 deletions

12
lib/next-in-path.zsh Normal file
View file

@ -0,0 +1,12 @@
# find next entry in PATH for wrapper scripts
# Usage: next-in-path <program name> <current $0>
next-in-path() {
entries=( $(which -a $1) )
index=${entries[(ie)$2]}
if [[ $index -le ${#entries} ]]; then
# found $0, use next entry
echo $entries[$((index + 1))]
else
echo $entries[1]
fi
}

0
lib/term-wrapper-alacritty Normal file → Executable file
View file