#!/bin/sh
#mv /usr/share/applications/hildon-status-menu/advanced-interface-switcher.desktop /tmp 
chmod +x /usr/bin/advifsw/*.sh
chmod +x /usr/bin/advifsw/*/*.sh
update-sudoers
ln -s /opt/maemo/usr/lib/hildon-desktop/advifswlib /usr/lib/hildon-desktop/advifswlib

if [ "$1" = "configure" ]; then
  gconftool-2 --makefile-install-rule /usr/share/gconf/schemas/advanced-interface-switcher.schemas
  gconf-schemas --register advanced-interface-switcher.schemas 
fi

gtk-update-icon-cache -f /usr/share/icons/hicolor

DISABLED_DIR=/usr/share/applications/hildon-status-menu/disabled
if [ ! -d $DISABLED_DIR ]; then
  mkdir $DISABLED_DIR
fi

if [ -f $DISABLED_DIR/../connui-bluetooth.desktop ]; then
  mv $DISABLED_DIR/../connui-bluetooth.desktop $DISABLED_DIR/
fi

PLUGINS_CONFIG=/etc/hildon-desktop/status-menu.plugins
if [ ! -f $PLUGINS_CONFIG.ais ]; then 
  cp $PLUGINS_CONFIG $PLUGINS_CONFIG.ais
fi
sed -i 's/connui-bluetooth\.desktop/advanced-interface-switcher\.desktop/g' $PLUGINS_CONFIG

#mv /tmp/advanced-interface-switcher.desktop /usr/share/applications/hildon-status-menu/

for f in $(find /opt/maemo/usr/lib/hildon-desktop/advifswlib/ -name *.pyc); do
  chown user:users $f
done

for f in $(find /opt/maemo/usr/lib/hildon-desktop/advifswlib/ -name *.pyo); do
  rm $f
done

exit 0
