Base on this guide:
- In iTerm2 go to Scripts > Manage > New Python Script (python runtime may need installing)
- Choose Basic script type
- Chose Long-Running Daemon script interval
- Name the script in some descriptive way like auto_theme_switch.py and paste this as content: