Select a random background image for Microsoft Teams. If you use the daily job, it will give you a new file every day to use as your background.
Note: This script only replaces the previously linked background image; other uploaded background files are kept.
Download this repository to any place on your machine and setup the python environment with:
pipenv installConfigure your settings by copying the config.example.yaml to config.yaml file and adjust the settings to your setup.
After that the script can be executed from the project dir with:
pipenv run randomizerTo execute the script from anywhere on your host, use the provided script in the scripts folder.
Note: Please adjust the path to pipenv on your host.
~/Workspace/teams-background-randomizer/scripts/runRandomizer.shTo let it run daily or every hour the preferred way is to use cron. To edit the cron file on Linux / MacOS execute the following commands
On MacOS make sure cron is allowed to have file access on your host.
# This will open the crontab file to edit
crontab -e
# Add a line when your script should be executed. See the two sample lines
# Execute it every minute - Useful for debugging
*/1 * * * * ~/Workspace/teams-background-randomizer/scripts/runRandomizer.sh
# Execute it every hour
0 */1 * * * ~/Workspace/teams-background-randomizer/scripts/runRandomizer.sh
# Execute it on startup
@reboot ~/Workspace/teams-background-randomizer/scripts/runRandomizer.shThe algorithm goes like this:
- Collect all background images from the image_source_dir
- Read the history file, how often every image was shown already
- Choose a new background randomly with weights. The less shown, the more likely it will be chosen.
- Copy it to a cache folder
- If enabled draw the logo with in dark or light variant on the background
- If enabled save the modified image also in the cache folder
- Replace or Set a hard link in the MS Teams upload folder. (If no hard link is found the first uploaded image will be replaced with it)
- MS Teams will now pick up the link to the random image in the cache folder