Skip to content

Instantly share code, notes, and snippets.

@davidhamann
Last active May 20, 2019 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidhamann/c8515a3aafe35b9a3207ae354d744636 to your computer and use it in GitHub Desktop.
Save davidhamann/c8515a3aafe35b9a3207ae354d744636 to your computer and use it in GitHub Desktop.
Quick and dirty way to switch vscode theme between light and dark. Put it into crontab for auto switch day/night.
#!/usr/bin/env python
import json
path = '/Users/your_user/Library/Application Support/Code/User/settings.json'
theme_day = 'Default Light+'
theme_night = 'Default Dark+'
with open(path, 'r') as settings_file:
data = json.load(settings_file)
data['workbench.colorTheme'] = theme_day if data['workbench.colorTheme'] == theme_night else theme_night
with open(path, 'w') as settings_file:
json.dump(data, settings_file,indent=4)
@davidhamann
Copy link
Author

davidhamann commented Aug 6, 2017

Put it into crontab like so:

#Mins   Hours  Days  Months   Day of the week                                                                                                                     
0       20     *     *        *              /your/path/switch_vscode_theme.py
0       9      *     *        *              /your/path/switch_vscode_theme.py

You can open the settings like so:

env EDITOR=vim crontab -e

@rapgru
Copy link

rapgru commented May 20, 2019

If you don't mind, have a look at my extension ThemeSwitch for a less dirty way of doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment