#!/bin/bash

cd /usr/share/skype

if ps -ef|grep -v grep|grep -q share/skype;then
  echo "Skype is already running"
  exit
fi

if [ $(ls -lL /lib/ld-linux.so.2 /usr/share/skype/lib32/ld-linux.so.2 2>/dev/null|cut -f1 -d/|uniq|wc -l) -ne 1 ];then
  echo "Warning! The 32bit subsystem and the skype 32bit libraries differ"
  echo "This may cause some problem if the version does not match"
fi
(
  rm -f ~/.Skype/Logs/skype*.log ~/.Skype/Logs/skype*.txt
  cd /usr/share/skype
  LD_PRELOAD=/usr/share/skype/lib32/libv4l/v4l2convert.so \
  GCONV_PATH=/usr/share/skype/lib32/gconv \
  QT_PLUGIN_PATH=/usr/share/skype/lib32/plugins \
  PULSE_LATENCY_MSEC=60 \
  LD_LIBRARY_PATH=/usr/share/skype/lib32/ \
    /usr/share/skype/lib32/ld-linux.so.2 --library-path /usr/share/skype/lib32 /usr/share/skype/skype
  echo
  rm -f ~/.Skype/Logs/skype*.log ~/.Skype/Logs/skype*.txt &
) &
