Multiple Instances of the Desktop App of Microsoft Teams
TL;DR Do you use Microsoft Teams and need to see more than 4 or 9 webcams? Read this!
Here is how I start four instances of Microsoft Teams, all of them using the desktop app. Read this post to learn how I do!
Microsoft Teams currently limits the number of video streams to 4, even if this number should increase in the next days to 9. What can you do if you need more, for example to handle an exam or different groups of a class? Well, you can for sure use different computers, each one running an instance of Teams, and split the participants in groups of 4 (or 9 in the near future). Obviously, this solution will not scale, especially if you are working at home, where the number of computers is likely to be insufficient for this purpose.
Well, what about running several virtual machine, each one running an instance of Teams? Also this solution may be very expensive in terms of resources! Anything better than this? Maybe we can start several instances of Teams on the same computer, wouldn’t it be nice? In fact, we can, for example using the web app, but it limits to a single video stream, which is of no help for our purposes. Actually, we need to run several instances of the desktop app, and I found a way to do this!
The trick is to add users to your OS, and run an instance of the desktop app for each user. I use linux, and thus I am going to explain how I do the magic on linux, but something similar should be doable also on other OSes (for example, for Window 10 check the answer of andreyc2019 here).
First of all, we have to create the users. We will disable login for them, and enable the use of speakers, microphone and webcam (actually, having more than one instance connected to the speakers is not a good idea). Run the following commands from a terminal to create user teams1 (feel free to change the username to something you like, and repeat the commands for as many instances of Teams you need):
$ sudo adduser --system --disabled-password teams1
$ sudo usermod -a -G audio,video teams1 # consider to not connect the speakers to these users
You have to run the above commands only once, for each user you need. After that, whenever you want to start an instance of Teams with user teams1, use the following commands:
$ xhost +"si:localuser:teams1"
$ sudo -u teams1 teams
The first command above instructs your X server to accept windows from user teams1, and the second command actually run Teams as user teams1. I advise you that the first time you will run Teams as user teams1, you will have to log in with your credentials; hence, if you need four instances of Teams, you are going to log in with your credentials four times. Luckily, the second time you will be logged in automatically (unless you explicitly ask to not do so).
To stop Teams, kill the process and disable the hosting of teams1’s windows with the following commands:
$ sudo -u teams1 killall -9 teams 2>/dev/null
$ xhost -"si:localuser:teams1"
Later, if you want to remove a user you created, for example if you do not need anymore to run several instances of Teams, use the following commands:
$ sudo userdel teams1
$ sudo rm -rf /home/teams1
I conclude this post with a script that automate the process for four instances of Teams, also introducing the possibility to layout the windows in four rectangles of a full HD monitor. If you save the script in `/bin/multi-teams.sh`, for example, the creation of users teams1, teams2, teams3 and teams4 is as simple as running
$ multi-teams.sh setup
To start the four instances just run
$ multi-teams.sh start
Layout the windows with
$ multi-teams.sh layout
and kill them when you are done by typing
$ multi-teams.sh stop
In a far future, when you will not need anymore this stuff, remove the users with
$ multi-teams.sh setdown
I hope that this may help you! Here is the script.
#!/bin/sh
WIDTH=1920
HEIGHT=1080
HWIDTH=$((WIDTH/2))
HHEIGHT=$((HEIGHT/2))
LEFT=(0 $HWIDTH 0 $HWIDTH)
TOP=(0 0 $HHEIGHT $HHEIGHT)
case "$1" in
setup)
for i in {1..4}; do
sudo adduser --system --disabled-password teams$i
#sudo usermod -a -G audio,video teams$i
done
;;
setdown)
for i in {1..4}; do
sudo userdel teams$i
sudo rm -rf /home/teams$i
done
;;
start)
for i in {1..4}; do
xhost +"si:localuser:teams$i"
sudo -u teams$i teams
done
;;
stop)
for i in {1..4}; do
sudo -u teams$i killall -9 teams 2>/dev/null
xhost -"si:localuser:teams$i"
done
;;
layout)
win_ids=`wmctrl -lp | grep " | Microsoft Teams$" | sed 's/ .*//' | tr '\n' ' '`
read -ra wins <<<"$win_ids"
if [ ${#wins[@]} -eq 4 ]; then
for i in {0..3}; do
wmctrl -i -r ${wins[$i]} -b remove,maximized_vert,maximized_horz
wmctrl -i -r ${wins[$i]} -b add,below
wmctrl -i -r ${wins[$i]} -e 0,${LEFT[$i]},${TOP[$i]},$HWIDTH,$HHEIGHT
done
else
echo "Unexpected output for wmctrl:" >&2
exit 3
fi
;;
*)
echo "Usage: $0 {setup|setdown|start|stop|layout}" >&2
exit 3
;;
esac
exit 0