#!/bin/sh

cp -f NicoEdit.mo /usr/share/locale/fr/LC_MESSAGES
cp -f nicoedit /usr/bin/
cp -f ../data/nicoedit.png /usr/share/pixmaps/
cp -f nicoedit.desktop /usr/share/applications/

FNDEDIT=''; FNDVIEW=''
[ "`find ./usr/bin ./usr/local/bin -maxdepth 1 -name beaver`" != "" ] && FNDEDIT='yes'
[ "` find ./usr/bin ./usr/local/bin -maxdepth 1 -name geany`" != "" ] && FNDEDIT='yes'
[ "` find ./usr/bin ./usr/local/bin -maxdepth 1 -name medit`" != "" ] && FNDEDIT='yes'
[ "` find ./usr/bin ./usr/local/bin -maxdepth 1 -name leafpad`" != "" ] && FNDVIEW='yes'

if [ "$FNDEDIT" != "yes" ];then
 echo '#!/bin/sh' > ./usr/local/bin/defaulttexteditor
 echo 'exec nicoedit "$@"' >> ./usr/local/bin/defaulttexteditor
 chmod 755 ./usr/local/bin/defaulttexteditor
fi

if [ "$FNDVIEW" != "yes" ];then
 echo '#!/bin/sh' > ./usr/local/bin/defaulttextviewer
 echo 'exec nicoedit "$@"' >> ./usr/local/bin/defaulttextviewer
 chmod 755 ./usr/local/bin/defaulttextviewer
 #some scripts call 'leafpad' explicitly...
 echo '#!/bin/sh' > ./usr/bin/leafpad
 echo 'exec nicoedit "$@"' >> ./usr/bin/leafpad
 chmod 755 ./usr/bin/leafpad
fi
