In iTerm2, in the menu bar go to Scripts > Manage > New Python Script
Select Basic. Select Long-Running Daemon
Give the script a decent name (I chose auto_dark_mode.py
)
Save and open the script in your editor of choice.
Copy and paste the script below and save
Go back to iTerm2, go to Scripts in the menu bar and select the script you just saved.
Try toggling Dark mode to see what happens! Reminder it's under Appearance in the System Settings
On line 8 is a list of profiles. Only these profiles will have their themes changes when the system theme changes. Add or remove profiles from this list to change which profiles get updated.
Note in the script below on lines 6 and 7 that we have a two variables, DARK_THEME
and LIGHT_THEME
. Change the values of these to whatever you like. The text is whatever appears in the dropdown in the iTerm2 settings under Profile/Color for when you'd want to change the theme manually.
After you change the script you'll have to stop and start the script if it's running already