How To Change Your Zoom Background With Code
Tags: coding, automation, bash, script
Published: 2024-01-09 05:51:26


In this blog, I'm going to share a [script](https://github.com/theRubberDuckiee/CLI-automations/blob/main/zoom_background.sh) you can use to change your Zoom background straight from your command line. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6w4y5d0vh4okgw4ssiqz.gif)

# Context
So, I work remote at [this company](https://warp.dev), and part of our work culture is that we set special Zoom backgrounds for birthdays, work anniversaries, and other special events. Here's an example from 2024:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v85ukywq9wyw8pahc139.png)

Now, I might possibly be the only person in the world who is impatient enough to feel this, but I **hate** having to go into Zoom to manually upload and change my custom background.

You have to go into your settings for virtual backgrounds, THEN click on the option to upload an image, THEN fumble around in finder to grab the right image to upload to Zoom.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2itw2g55uyriz1dm8xcn.png)

## My Preferred Solution

Instead of doing it manually, I wrote a script in bash that would automate this manual work for you. Here is the script:

```
#!/bin/bash

ZOOMPATH={{zoom_path}}
UUID=$(find "{{zoom_path}}" -type f -not -name ".*" | head -n1 | awk -F: '{print $1}')
RECENTFILE=$(find "{{downloads_path}}" -type f -exec stat -f "%m %N" {} \; | sort -rn | head -n1 | awk -F/ '{print $NF}')
BGPATH="{{downloads_path}}/$RECENTFILE"

echo "Moving $BGPATH to $UUID"
cp -R "$BGPATH" "$UUID"
```
This script is basically taking your most recently downloaded file and replacing whatever default virtual background you have in Zoom with that downloaded file. 

Your `downloads_path` is most likely something like `/Users/<your_username>/Downloads` or `$HOME/Downloads`, but I trust you'll be able to find that path yourself if you moved around your Downloads folder.

Your `zoom_path` can be found by running `mdfind -name "VirtualBkgnd_Custom"`. If it helps, my path was `$HOME/Library/Application Support/zoom.us/data/VirtualBkgnd_Custom`. When you run the command, you'll get an output that looks something like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/403q0ntx014n7nt44dd5.png)


## Making It Even Easier

After writing the script, I wanted to:

1. Save this script somewhere so I didn't have to rewrite it every time.

2. Make this widely accessible for the rest of my team so they could enjoy this automation as well.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ebhl82ahpveskk8bsej7.jpeg)

To do this, I created a new workflow in my Warp terminal and pasted in my script and pressed autofill. For those of you who aren't familiar, [workflows](https://docs.warp.dev/features/warp-drive/workflows) are kind of like aliases that you have in your shell config (.zshrc file, for example) in the sense that it gives you a way to quickly run complex & hard-to-remember commands. I like workflows slightly better because I can share the workflow with my team (if I prefer) and it also auto-parameterizes my command/script so I can vary things like paths, secrets, or more.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hxlx0zwjiupc6c3z6tef.gif)

_If you're curious about the terminal I'm referring to above, [Warp](https://warp.dev) is a Rust-based terminal with AI built in. I like it because it has things like autocompletions, history search, click-to-edit, and theming out-of-the-box. Feels super modern compared to the default Mac terminal or iTerm2. And if you do want to try it out, use my [referral link](https://app.warp.dev/referral/7MPKYN) & get a free theme. (I work there.)_

## Conclusion

And finally, if you want to see 1-minute demo of this Zoom-background-changing-script in action, you can check this Loom out. Thanks for reading!

{% embed https://www.loom.com/share/5203b971abe5488fa69b22c795ec0de1?sid=effff9c2-748a-4957-b1c4-99db709ceefd %}