if command -v kaiming > /dev/null; then
    # set XDG_DATA_DIRS to include Kaiming installations

    new_dirs=$(
        (
            unset G_MESSAGES_DEBUG
            echo "${XDG_DATA_HOME:-"$HOME/.local/share"}/kaiming"
            GIO_USE_VFS=local
        ) | (
            new_dirs=
            while read -r install_path
            do
                share_path=/opt/kaiming/share
                case ":$XDG_DATA_DIRS:" in
                    (*":$share_path:"*) :;;
                    (*":$share_path/:"*) :;;
                    (*) new_dirs=${new_dirs:+${new_dirs}:}$share_path;;
                esac
            done
            echo "$new_dirs"
        )
    )

    export XDG_DATA_DIRS
    XDG_DATA_DIRS="${new_dirs:+${new_dirs}:}${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
    echo "$XDG_DATA_DIRS"
fi
