How I made a presentation remote using python

A remote made for making presentations easier by enabling all the members to have access to change the slide and control the flow of the presentation

ยท

5 min read

My motive ๐Ÿ‘จโ€๐Ÿ’ป

Despite several test runs, we were unable to grasp a seamless execution of our presentation during a presentation with roughly 10 speakers because we were utilising a lot of 'next slide please'.

Hence presenting to you, a remote made for making presentations easier by enabling all the members to have access to change the slide and control the flow of the presentation in real time

Here's the github repo if you want to get straight into it

How the magic happens ๐Ÿช„

The primary functionality of this application is divided into two modules:

  • A remote control that transfers the signal to the receiver
  • The receiver receives the commands and executes them on the host computer

When you interact with the remote, a document is added to the database (firestore)

# Send info to receiver
def add_doc(self, action):
    self.db.collection("remote").document("current").collection("clicks").add({
        "action": action
    })

Which is then picked up by the receiver, which is always listening for these events. The receiver then simulates the necessary keystroke on the host system.

# Action was performed by the remote
def onSnapshot(snapshot, doc, time):
    send_input(doc[0].document.to_dict()["action"])

And this is all there is to it

How to make it work โš™๏ธ

You will have to setup a few things before you can get this working

  • Setup python and have the dependencies installed
  • Setup your firebase project
  • Optionally converting this application into a binary for easier sharing and usage

Cloning the repository

Repository available on github

# If you use ssh
git clone git@github.com:parnavh/presentation-remote-py.git

# If you use https
git clone https://github.com/parnavh/presentation-remote-py.git

Getting Python ready ๐Ÿ

You will have to setup python on your machine if not done yet by visiting the official website and downloading and installing a release which should be quite straightforward. asd The most latest version was 3.10.0 at the time of writing this blog, since it was launched recently I was having some issues with pyinstaller (which we will use to make an executable later), I would recommend using 3.9 instead. Once you have got your python up and running, cd into the directory and install the dependencies by running

pip install -r .\requirements.txt

After that is done we can move on to the next step

Getting firebase ready ๐Ÿ”ฅ

Go to the firebase console and create a new project

create.png

Now that you have a firebase project setup, we can enable the firestore database, head on to the firestore section and create the database

firestore.png

Create the database in test mode and chose the region closest to you Now that the database is created, we can create the collection in which the documents will be added. Create a collection with the collection id remote and add a document current and then hit save

collection

Start a new collection in the current document and name it clicks and add a random document to the collection temporarily as shown in the following image:

subcollection

Now your database should have the following structure: /remote/current/clicks/ All the click events will be added using the remote in the clicks collection. Once this structure is all set, we can move on to downloading the credentials to access this database

Head on to the project settings from the gear icon in the top left as show in the image:

gotosettings

Go to the service account section, and scroll down till you see Generate new private key in the admin sdk section click it, and confirm generating a key.

privatekey

This will generate a json file containing your admin sdk credentials which we will be storing in the root of our previously cloned repository as credentials.json and that's all set from the firebase front

Now that all the setup has been finished, you have to run python receiver.py on the system from where the presentation is present, and run python remote.py on the systems where you want to control the presentation from.

Build your executable

If you are looking to get it done asap, I have the binary in the releases but it will require the credentials.json in the same directory for both the modules hence I suggest you build your own

Building your own executable will mean that you can share the file and anyone can run the binary on their machine and it would just work, so here's how to do it:

cd into the repository and install pyinstaller by running

pip install pyinstaller

Now substitute the path to credentials.json in the code with the contents of the credentials.json file

Example:

# From
    creds = credentials.Certificate("./credentials.json")
# To
    myCredentials = {...} # Content in the credentials.json
    creds = credentials.Certificate(myCredentials)

You will have to create 2 files:

  • hook-gcloud.py
    from PyInstaller.utils.hooks import copy_metadata
    datas = copy_metadata('gcloud')
    
  • hook-grpc.py
    from PyInstaller.utils.hooks import collect_data_files
    datas = collect_data_files('grpc')
    

Save these files in Lib\site-packages\PyInstaller\hooks from the directory of your python install. Example if your python is installed in C:\python save the files in C:\python\Lib\site-packages\PyInstaller\hooks

Now run the pyinstaller which will convert the py file to a executable

# For remote.py
pyinstaller --onefile -w 'remote.py'

# For receiver.py
pyinstaller --onefile 'receiver.py'

The receiver runs in the background with no gui, and the remote has a basic tkinter gui with left and right buttons as so:

receiver

This was all you needed to get started! I will be developing more features which include a dashboard, user accounts/roles and much more.

Make sure to star this repository on github to stay posted or simply to show your support for this project!

This was my first blog and I hope to have conveyed something new to you today I am open to feedbacks and suggested improvements to better my content.

Did you find this article valuable?

Support Parnav Harinathan by becoming a sponsor. Any amount is appreciated!

ย