mirror of
https://github.com/phillipberndt/autorandr
synced 2025-02-17 20:17:06 +00:00
XDG search and *.d dir filternig
This commit is contained in:
parent
6511bf29f9
commit
6b27e2a62d
@ -1,8 +1,9 @@
|
|||||||
# autorandr/auto-disper completion by Maciej 'macieks' Sitarz <macieks@freesco.pl>
|
# autorandr/auto-disper completion by Maciej 'macieks' Sitarz <macieks@freesco.pl>
|
||||||
|
# XDG additions and service dir filtering by Vladimir-csp
|
||||||
|
|
||||||
_autorandr ()
|
_autorandr ()
|
||||||
{
|
{
|
||||||
local cur prev opts lopts prfls
|
local cur prev opts lopts prfls AR_DIRS OIFS
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
@ -10,10 +11,27 @@ _autorandr ()
|
|||||||
|
|
||||||
opts="-h -c -s -r -l -d"
|
opts="-h -c -s -r -l -d"
|
||||||
lopts="--help --change --save --remove --load --default --force --fingerprint --config --dry-run"
|
lopts="--help --change --save --remove --load --default --force --fingerprint --config --dry-run"
|
||||||
if [ -d ~/.autorandr ]; then
|
|
||||||
prfls="`find ~/.autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
|
# find system-level autorandr dirs
|
||||||
elif [ -d ~/.config/autorandr ]; then
|
OIFS="$IFS"
|
||||||
prfls="`find ~/.config/autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
|
IFS=':'
|
||||||
|
for DIR in ${XDG_CONFIG_DIRS:-/etc/xdg}
|
||||||
|
do
|
||||||
|
IFS="$OIFS"
|
||||||
|
[ -d "$DIR/autorandr" ] && AR_DIRS=( "${AR_DIRS[@]}" "$DIR/autorandr" )
|
||||||
|
done
|
||||||
|
IFS="$OIFS"
|
||||||
|
|
||||||
|
# find user-level autorandr dir
|
||||||
|
if [ -d "$HOME/.autorandr" ]; then
|
||||||
|
AR_DIRS=( "${AR_DIRS[@]}" "$HOME/.autorandr" )
|
||||||
|
elif [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/autorandr/" ]; then
|
||||||
|
AR_DIRS=( "${AR_DIRS[@]}" "${XDG_CONFIG_HOME:-$HOME/.config}/autorandr/" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${AR_DIRS}" ]
|
||||||
|
then
|
||||||
|
prfls="$(find "${AR_DIRS[@]}" -mindepth 1 -maxdepth 1 -type d ! -name "*.d" -printf '%f\n' | sort -u)"
|
||||||
else
|
else
|
||||||
prfls=""
|
prfls=""
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user