# remove obsolete options from AUDACIOUS_OPTS
list_remove AUDACIOUS_OPTS '--enable-statusicon' &&
list_remove AUDACIOUS_OPTS '--disable-statusicon' &&
list_remove AUDACIOUS_OPTS '--enable-aosd-xcomp' &&
list_remove AUDACIOUS_OPTS '--disable-aosd-xcomp' &&
list_remove AUDACIOUS_OPTS '--enable-skins' &&
list_remove AUDACIOUS_OPTS '--disable-skins' &&
list_remove AUDACIOUS_OPTS '--enable-lyricwiki' &&
list_remove AUDACIOUS_OPTS '--disable-lyricwiki' &&
list_remove AUDACIOUS_OPTS '--enable-xsf' &&
list_remove AUDACIOUS_OPTS '--disable-xsf' &&
list_remove AUDACIOUS_OPTS '--enable-psf' &&
list_remove AUDACIOUS_OPTS '--disable-psf' &&
list_remove AUDACIOUS_OPTS '--enable-gtkui' &&
list_remove AUDACIOUS_OPTS '--disable-gtkui' &&

# remove deprecated options
if [[ -n $AUDACIOUS_IPV6 ]]; then
  persistent_remove AUDACIOUS_IPV6
fi &&
if [[ -n $AUDACIOUS_AD ]]; then
  persistent_remove AUDACIOUS_AD
fi &&

if [[ ! -v AUDACIOUS_OPTS ]]; then
  persistent_add AUDACIOUS_OPTS
fi &&

# backport legacy options
for o in AUDACIOUS_STATUS AUDACIOUS_OSD AUDACIOUS_COSD AUDACIOUS_SONGCHANGE \
         AUDACIOUS_HOTKEY AUDACIOUS_MPRIS AUDACIOUS_GTKUI AUDACIOUS_SKINS \
         AUDACIOUS_LYRIC; do
  if [[ -n ${!o} ]]; then
    list_add "AUDACIOUS_OPTS" "${!o}" &&
    persistent_remove ${o}
  fi
done &&

config_query_option AUDACIOUS_OPTS \
                    "Enable Song Change Plugin?" y \
                    "--enable-songchange" \
                    "--disable-songchange" &&

config_query_option AUDACIOUS_OPTS \
                    "Enable mpris2 plugin?" y \
                    "--enable-mpris2" \
                    "--disable-mpris2"
