- if [ -d ~/.autorandr ]; then
- prfls="`find ~/.autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
- elif [ -d ~/.config/autorandr ]; then
- prfls="`find ~/.config/autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
+
+ # find system-level autorandr dirs
+ OIFS="$IFS"
+ 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)"