gentoo-overlay/net-im/skype/files/sDaemonWrapper-r1

67 lines
2.1 KiB
Bash

#!/bin/bash
#
# Wrapper script to run Skype with sound wrapper when possible
logfile="${HOME}/.Skype/skype.log"
progname="skype"
progpath="/opt/${progname}/"
progopts="--resources-path ${progpath}"
shellcheck1=` which artsshell 2> /dev/null `
shellcheck2=` which esd 2> /dev/null `
artsdcheck=` ps x | grep artsd | grep -v grep `
## We use ps ax for esd as esd can be used globaly for all users.
esdcheck=` ps ax | grep "esd ." | grep -v grep `
skypecmd="${progpath}${progname}.bin"
wrapsound="yes"
#Use 32bits wrapper in 64 bits system
xdspsuffix=""
if [ `uname -m` == "x86_64" ]; then
xdspsuffix=32
fi
[ "$1" == "oss" ] && wrapsound="no"
[ -d "$(dirname "${logfile}")" ] || mkdir "$(dirname "${logfile}")"
echo "===== " `date` " =====" > ${logfile}
if [[ -z ${shellcheck1} && -z ${shellcheck2} ]]
then
echo "No installed artsshell or esd found"
echo "Assuming you're running no sound daemon"
echo "Starting ${progname} without a sound wrapper" | tee --append "${logfile}"
else
if [[ ${wrapsound} == "yes" && ${shellcheck1} == $(artsc-config --arts-prefix)/bin/artsshell && -n ${artsdcheck} ]]
then
echo "Running artsd found"
echo "Starting artsd wrapped ${progname}" | tee --append "${logfile}"
skypecmd="env MALLOC_CHECK_=0 artsdsp${xdspsuffix} -m ${skypecmd}"
elif [[ ${wrapsound} == "yes" && ${shellcheck2} == /usr/bin/esd && -n ${esdcheck} ]]
then
echo "Running esd found"
echo "Starting esd wrapped ${progname}" | tee --append "${logfile}"
skypecmd="esddsp${xdspsuffix} ${skypecmd}"
else
if [ ${wrapsound} == "yes" ]
then
echo "No running artsd or esd found"
else
echo "Use of sound-daemon disabled"
fi
echo "Starting ${progname} without sound daemon" | tee --append "${logfile}"
fi
fi
#Going to "homedir"
cd ${progpath}
echo "${skypecmd} ${progopts}" >> ${logfile}
echo "=========================================="
${skypecmd} ${progopts} >> ${logfile} 2>> ${logfile}
if [[ $? -ne 0 ]] ; then
echo "Running wrapped Skype failed, trying not-wrapped mode..."
echo "=========================================="
skypecmd="${progpath}${progname}.bin"
${skypecmd} ${progopts} >> ${logfile} 2>&1
fi
exit $?