Skip to content

Instantly share code, notes, and snippets.

@WaterSibilantFalling
Created September 21, 2017 14:09
Show Gist options
  • Save WaterSibilantFalling/0f3a8cce270c094282720f1e0eb114a0 to your computer and use it in GitHub Desktop.
Save WaterSibilantFalling/0f3a8cce270c094282720f1e0eb114a0 to your computer and use it in GitHub Desktop.
does a range of preparations, and then runs skype
#!/bin/bash
# this program sets up skype to run on linux without pulseaudio
#
# already running. There are two options:
# 1. run pulseaudio just before skype, then kill it when finished with skype
# 2. use the apulse library to fool skype into thinking that there is pulse audio.
# apulse relies on alsa - it just passes pulseaudio commands through to ALSA
# requirements:
# xmessage (or some other messaging program)
#
# if using pulseaudio:
# pulseaudio (unless setting USE_REAL_PULSE to 0)
# (i.e. no '1' is passed to this script)
# pavucontrol (iff using pulseaudio) (optional)
#
# if not using pulseaudio
# apulse, downloadable as 'apulse-master' from https://github.com/i-rinat/apulse
# qasmixer (optional)
# gksu (optional - the v4l2usp must be run as root: sudo will NOT do. )
# ----- parapmeters ----------------------------------
# read the single parameter: '1' means 'use the real pulseaudio'
USE_REAL_PULSE=0
if [[ "x$1" == "xpulse" ]]
then
USE_REAL_PULSE=1
elif [[ "x$1" != "x" ]]
then
xmessage "corrupt parameter ($1) to sdmskype";
exit ;
fi
# ----- preparations ---------------------------
# this blocks until dismissed
xmessage "Connect the webcam (if you want to)"
# if NOT using pulseaudio:
if [[ "x$USE_REAL_PULSE" == "x0" ]]
then
# currently, with just alsa, alsa.conf
# I cannot get the dmix bit to work, so can
# only have one sound app running at one time
# (multiple sound apps is the SOLE benefit of
# pulseaudio)
xmessage "about to kill iceweasel and audacious"
# currently 2015-11-18 only one program can use non-pulse sound
killall audacious
#killall firefox
# the preload is for the update to skype 2014-09-09 or earlier
# to make the video camera work
export LD_PRELOAD=/usr/lib/i386-linux-gnu/libv4l/v4l1compat.so
# these are the libraries to fool skype into thinking that it is running
# pulseaudio
# this is a separate directory for the 'apulse' libraries
export LD_LIBRARY_PATH=/usr/lib/i386-linux-gnu/sdm_pulseRemoveLibs:$LD_LIBRARY_PATH
fi
# ----- support programs ------------------------
if [[ $USE_REAL_PULSE == "1" ]]
then
PULSE_ALREADYRUNNING=`sudo pidof pulseaudio`
if [[ "x$PULSE_ALREADYRUNNING" == "x" ]]
then
echo "==== Starting pulseaudio ==="
# remove stale pids and shit
rm -fr /run/user/1000/pulse
rm -fr /run/shm/pulse-shm-*
#NO: fucks the sound: export PULSE_LATENCY_MSEC=30
urxvt -g 200x100 -title "pulseaudio messages" -hold -e bash -c 'pulseaudio -vvvvv' &
pulseaudio_terminal_pid=$!
sleep 3
fi
# pavucontrol &
# pavucontrol_pid=$!
killall xaumix;
xaumix &
sleep 3
export QT_GRAPHICSSYSTEM="native"
export QT_X11_NO_MITSHM=1
gksu v4l2ucp &
v412ucp_pid=$!
sleep 3
else # [[ "$USE_REAL_PULSE" == '0' ]]
qasmixer &
qasmixer_pid=$!
sleep 10
export QT_GRAPHICSSYSTEM="native"
export QT_X11_NO_MITSHM=1
gksu v4l2ucp &
v412ucp_pid=$!
sleep 10
fi
# ----- now run skype --------------------------
export QT_GRAPHICSSYSTEM="native"
export QT_X11_NO_MITSHM=1
/usr/bin/skype &
skype_pid=$!
# ----- killing skype when done ----------------
sleep 5;
echo
echo "**********************************"
echo "Type \"done\" when done with skype"
echo "**********************************"
echo
ENDSTRING="aaa";
while [[ "$ENDSTRING" != "done" ]]
do
aumix -i 100 ; # capture
# aumix -m 100 ; # mic playback, not capture
sleep 0.5 ;
read -t 0.5 ENDSTRING ;
done
kill $skype_pid
# mute the microphone now we are done
aumix -i 0;
# ----- clean-up now skype has finished -----------------------
if [[ $USE_REAL_PULSE == "1" ]]
then
if [[ "x$PULSE_ALREADYRUNNING" == "x" ]]
then
kill $pulseaudio_terminal_pid;
/usr/bin/killall -q pulseaudio
fi
sudo /usr/bin/killall -q v4l2ucp
sudo /usr/bin/killall -q "rtkit-daemon"
sudo /usr/bin/killall -q timidity
sleep 1
if [[ "x$PULSE_ALREADYRUNNING" == "x" ]]
then
/usr/bin/killall -q -9 pulseaudio
sudo rm -fr /tmp/pulse*
fi
sudo /usr/bin/killall -q -9 v4l2ucp
sudo /usr/bin/killall -q -9 "rtkit-daemon"
sudo /usr/bin/killall -q -9 timidity
sudo rm -fr /tmp/skype*
else
kill $qasmixer_pid;
sudo /usr/bin/killall -q v4l2ucp
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment