Juanse Marquez

Mi blog personal

Let students see teacher’s screen

03/04/2021 — Juanse Marquez

I’m sharing a script that I find useful in the school where I work.

Its goal is that every student can see the teacher’s screen in a computer classroom, so that the teacher can show some complex procedure.


(Disponible en español)

This are the prerequisites:

  • Every computer is running GNU/Linux.
  • Students’ computers have the VNC client vinagre installed (most Debian-like distros do by default).
  • Every computer has a static ip address (in this example, we supose they go from 192.168.10.2 to 192.168.10.25).
  • The teacher’s user has passwordless ssh access in the students’ computers. (How?).
  • The username is the same in every student computer.

Avoiding long preambles, this is the script:

#!/bin/bash
#Change the following configs, according to your classroom's ip setting:
teacher_ip="192.168.10.99"
first_pc=2
last_pc=25

#Student's user
echo "Enter students' username: "
read user

#Command that will run in the student's computers
com="export DISPLAY=:0.0 && vinagre -f vnc://$teacher_ip"

echo "A window will open. Check:"
echo '"Allow other users to see my desktop"'
echo "Press ENTER to continue"
read sth
vino-preferences 
echo "In a few seconds, everyone will be watching this screen..."

for pc in $(seq $first_pc $last_pc); do
    ssh $user@192.168.10.$pc "$com" &
done

You need to copy the code above, open a text editor, and paste it there. Then, save it under the name you choose, for example, see.sh.

Then, we allow execution permission, typing on a terminal: chmod 744 see.sh

Finally, we run it from a terminal: ./see.sh

Then we show the procedure, while every student is watching our screen.

When we’re done, we should “give them back control” on their computers. So we need to run the following script:

#!/bin/bash
first_pc=2
last_pc=25
echo "Enter students' username: "
read user
com="killall vinagre"
for pc in $(seq $first_pc $last_pc); do 
    ssh $user@192.168.10.$pc "$com" &
done

I hope it’s useful for you as it is for me.

Tags: english, bash, aula-de-informatica, educacion

¿Commentarios? / Comments? Tweet