Reputation: 79
I want to be able to set/select a theme at a given time through the extension API.
Example:
6:00 PM — Set theme "OneDark Pro"
So far, I've been reading the extension API docs and have not found information that could help me in this manner.
This would be my first extension & Typescript project, so I'm sure I might be missing an obvious point.
vscode.ThemeColor.set('themeName');
Upvotes: 1
Views: 242
Reputation: 34148
There is a "workbench.colorTheme"
setting (note that it's only available for workspace-local settings.json
files). Additionally, there's an API to read and modify settings. This means you can do something like this:
var folders = vscode.workspace.workspaceFolders;
if (folders !== undefined) {
vscode.workspace.getConfiguration('workbench', folders[0].uri)
.update(
'colorTheme', 'themeName', vscode.ConfigurationTarget.Workspace);
}
Note: this logic is simplified and assumes that the workspace only consists of a single folder / won't work for multi-root workspaces.
Upvotes: 1