Last active
September 14, 2021 01:27
-
-
Save PeterNerlich/bae25c7eedd838f25e93cfb383e7dfd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
######################################## | |
## CC BY-NC-SA 4.0 ## | |
## Original script by Peter Nerlich ## | |
## This code is provided as-is, you ## | |
## are responsible for anything you ## | |
## do with it and the consequences. ## | |
######################################## | |
dev="/dev/video10" # The device file to create as a loopback device. Keeping this fixed speeds things up as you dont have to change it in OBS all the time. | |
devname="OBS" # The name to give the device. Will show up in Zoom. | |
aj_file="my_snapshot.xml" # The aj-snapshot file to restore from if you choose to do so. | |
function check_v4l2() { | |
v4l2-ctl --list-devices | grep -Pzoq "v4l2loopback.*\n.*$dev" | |
} | |
function cleanup_v4l2() { | |
sudo modprobe -r v4l2loopback | |
} | |
function setup_v4l2() { | |
sudo modprobe v4l2loopback video_nr=10 exclusive_caps=1 card_label=$devname | |
} | |
function check_obs() { | |
pgrep obs | |
} | |
function kill_obs() { | |
pkill obs | |
} | |
function run_obs() { | |
obs &> /dev/null & | |
} | |
function check_zoom() { | |
pgrep zoom | |
} | |
function kill_zoom() { | |
pkill zoom | |
} | |
function run_zoom() { | |
XDG_CURRENT_DESKTOP=gnome flatpak run us.zoom.Zoom &> /dev/null & | |
} | |
function check_carla() { | |
pgrep carla | |
} | |
function kill_carla() { | |
pkill carla | |
} | |
function run_carla() { | |
carla &> /dev/null & | |
} | |
function run_aj_restore() { | |
aj-snapshot -x -r "$aj_file" | |
} | |
check_v4l2 | |
if [ $? -eq 0 ]; then | |
echo "Video loopback device found." | |
read -p "- Create video loopback device? (y[N]c) " yn | |
case $yn in | |
[Cc]* ) cleanup_v4l2 && setup_v4l2;; | |
[Yy]* ) setup_v4l2;; | |
* ) ;; | |
esac | |
else | |
read -p "- Create video loopback device? ([Y]nc) " yn | |
case $yn in | |
[Cc]* ) cleanup_v4l2 && setup_v4l2;; | |
[Nn]* ) ;; | |
* ) setup_v4l2;; | |
esac | |
fi | |
echo "" | |
check_obs | |
if [ $? -eq 0 ]; then | |
echo "OBS is running." | |
read -p "- Start OBS? (y[N]c) " yn | |
case $yn in | |
[Cc]* ) kill_obs && run_obs;; | |
[Yy]* ) run_obs;; | |
* ) ;; | |
esac | |
else | |
read -p "- Start OBS? ([Y]nc) " yn | |
case $yn in | |
[Cc]* ) kill_obs && run_obs;; | |
[Nn]* ) ;; | |
* ) run_obs;; | |
esac | |
fi | |
echo "" | |
echo "##############" | |
echo "" | |
echo "- start v4l2 output to $dev" | |
echo "" | |
echo "- ensure all videos are monitored" | |
echo " (Advanced Audio Properties → Audio Monitoring → Monitor and Output" | |
echo " view with 'Active Sources Only' unchecked)" | |
echo "" | |
check_zoom | |
if [ $? -eq 0 ]; then | |
echo "Zoom is running." | |
read -p "- Start Zoom? (y[N]c) " yn | |
case $yn in | |
[Cc]* ) kill_zoom && run_zoom;; | |
[Yy]* ) run_zoom;; | |
* ) ;; | |
esac | |
else | |
read -p "- Start Zoom? ([Y]nc) " yn | |
case $yn in | |
[Cc]* ) kill_zoom && run_zoom;; | |
[Nn]* ) ;; | |
* ) run_zoom;; | |
esac | |
fi | |
echo "" | |
echo "##############" | |
echo "" | |
echo "- enter meeting" | |
echo "" | |
echo "- use $devname as webcam" | |
echo "" | |
echo "- Share Screen → Advanced → Computer Audio" | |
echo "" | |
check_carla | |
if [ $? -eq 0 ]; then | |
echo "Carla is running." | |
read -p "Start Carla? (y[N]c) " yn | |
case $yn in | |
[Cc]* ) kill_carla && run_carla;; | |
[Yy]* ) run_carla;; | |
* ) ;; | |
esac | |
else | |
read -p "Start Carla? ([Y]nc) " yn | |
case $yn in | |
[Cc]* ) kill_carla && run_carla;; | |
[Nn]* ) ;; | |
* ) run_carla;; | |
esac | |
fi | |
echo "" | |
echo "##############" | |
echo "" | |
echo "- Assign each video of 'OBS/OBS-Monitor' to 'Zoom VoiceEngineLoopback'" | |
read -p " Try to restore that from file '$aj_file' using aj-snapshot? All other audio connections will be removed! ([Y]n) " yn | |
case $yn in | |
[Nn]* ) ;; | |
* ) run_aj_restore;; | |
esac | |
echo "" | |
echo "DONE!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment