source "${GRIMOIRE}/FUNCTIONS" &&

config_query_option POLYBAR_OPTS "Build ipc messager?" y \
                                 "-DBUILD_IPC_MSG=ON" \
                                 "-DBUILD_IPC_MSG=OFF" &&

config_query_option POLYBAR_OPTS "Enable xrandr support?" y \
                                 "-DWITH_XRANDR=ON" \
                                 "-DWITH_XRANDR=OFF" &&

if list_find "${POLYBAR_OPTS}" "-DWITH_XRANDR=ON"; then
  if spell_ok libxcb && ! is_version_less $(installed_version libxcb) 1.12; then
    config_query_option POLYBAR_OPTS "Enable xrandr monitor support?" y \
                                     "-DWITH_XRANDR_MONITORS=ON" \
                                     "-DWITH_XRANDR_MONITORS=OFF"
  else
    message "${PROBLEM_COLOR}libxcb version is lower than 1.12, xrandr monitor support selection not available.${DEFAULT_COLOR}"
  fi
fi &&

# see BUILD for the following 3 options
list_remove POLYBAR_OPTS '-DWITH_XRENDER=ON' &&
list_remove POLYBAR_OPTS '-DWITH_XDAMAGE=ON' &&
list_remove POLYBAR_OPTS '-DWITH_XSYNC=ON' &&

config_query_option POLYBAR_OPTS "Enable xcomposite support?" n \
                                 "-DWITH_XCOMPOSITE=ON" \
                                 "-DWITH_XCOMPOSITE=OFF" &&

config_query_option POLYBAR_OPTS "Enable xkeyboard support?" y \
                                 "-DWITH_XKB=ON -DENABLE_XKEYBOARD=ON" \
                                 "-DWITH_XKB=OFF -DENABLE_XKEYBOARD=OFF" &&

config_query_option POLYBAR_OPTS "Enable trace logging?" y \
                                 "-DDEBUG_LOGGER=ON" \
                                 "-DDEBUG_LOGGER=OFF" &&

config_query_list POLYBAR_NETWORK "Enable network support?" \
                                  libnl \
                                  wireless_tools \
                                  none
