Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Sundial – Day/Night Theme SwitchNew to Visual Studio Code? Get it now.

Sundial – Day/Night Theme Switch

Marvin Heilemann

|
2,953 installs
| (10) | Free
Change your VS Code theme/settings based on your sunset, sunrise, system appearance or other preferences!
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

☀️ Sundial ☀️

Change your VS Code theme/settings based on your sunset, sunrise, system appearance or other preferences!

Visual Studio Marketplace Visual Studio Marketplace Visual Studio Marketplace Maintainability Total alerts Language grade: JavaScript

  • Installation
  • Keybindings
  • Commands
  • Settings
    • Automatically set by current location
    • Automatically set by latitude and longitude
    • Automatically set by OS appearance
    • Execution order
    • Examples
  • Development
    • Commits
    • Releases

Sundial changes your theme and VS Code settings (if needed) based on your day and night cycle or other options, you choose. It is inspired by the OSX Mojave dynamic backgrounds and Night Owl for Mac. It should reduce eye pain when working in the night or on the day. Humans should not strain their eyes too much, it's not recommended to have a light theme in the night and vice versa.

Whenever you have ideas for this project, things you would like to add or you found a bug, feel free to create an issue or start contributing! 😇

Buy me a Gluten-free Bread

VSCode Sundial

Installation

You can simply install any VS Code extension via the VS Code Marketplace. Just click the banner below:

Install VS Code extension Sundial

⚠️ IMPORTANT: Since VS Code 1.42.0 automatically changing the theme based on OS appearance is build in, if you want to use this plugin anyway you must disable this options with "window.autoDetectColorScheme": false

Keybindings

Sundial contributes the following keybindings:

Platform Keybinding Description
Windows ctrl+alt+t Toggles between your day/night theme.
Mac ctrl+cmd+t Toggles between your day/night theme.

Note: Whenever you use one of these keybindings, Sundial will be disabled.

Commands

Sundial contributes the following commands:

Command Description
Sundial: Switch to night theme 🌑 Switches to your night theme.
Sundial: Switch to day theme 🌕 Switches to your day theme.
Sundial: Toggle Day/Night Theme Toggles between your day/night theme.
Sundial: Enable extension Continues automation and enables extension.
Sundial: Disable extension Disables extension.
Sundial: Pause until next circle Pause until next day/night circle.

Note: Whenever you use one of the first three commands, Sundial will be disabled.

Settings

Sundial contributes the following settings:

Setting Default Description
workbench.preferredLightColorTheme Default Light+ Name of the theme of choice for your day work.
workbench.preferredDarkColorTheme Default Dark+ Name of the theme of choice for your night work.
sundial.sunrise 07:00 Set a time when your day starts in 24 hours format.
sundial.sunset 19:00 Set a time when your night starts in 24 hours format.
sundial.dayVariable 0 Set a variable to change the theme X minutes before or after sunrise.
sundial.nightVariable 0 Set a variable to change the theme X minutes before or after sunset.
sundial.daySettings {} An object of VSCode settings applied on the day.
sundial.nightSettings {} An object of VSCode settings applied on the night.
sundial.interval 5 Set a interval in which sundial should check the time in minutes.

⚠️ Don't forget to set "window.autoDetectColorScheme": false

If you set the interval to zero (0) sundial will not periodically check the time but still when VS Code triggers some editor events.

On both daySettings and nightSettings they will override your Workbench VSCode settings. Please make sure both have the same properties otherwise they will not change since Sundial is not remembering the settings you have set before!

Automatically set by current location

Sundial will get your geolocation from Free IP Geolocation API and check your internet connection via Cloudflares 1.1.1.1 DNS-Server.

Setting Default Description
sundial.autoLocale false Updates your location based on your geolocation.

Automatically set by latitude and longitude

You can get your geolocation here: Free IP Geolocation API

Setting Default Description
sundial.latitude ⊘ e.g. "50.110924"
sundial.longitude ⊘ e.g. "8.682127"

Automatically set by OS appearance

Since VS Code version 1.42.0 it is now build in so you don't need this extension for this options.

{
  "window.autoDetectColorScheme": true
}

Read more about the implementation here:

  • https://github.com/microsoft/vscode/issues/61519
  • https://github.com/microsoft/vscode/pull/86600
  • https://github.com/microsoft/vscode/pull/87405

Execution order

Sundial will check your settings in the following order and if one setting is present the next coming will be ignored.

  1. sundial.latitude and sundial.longitude
  2. sundial.autoLocale
  3. sundial.sunrise and sundial.sunset

Examples

{
  "window.autoDetectColorScheme": false, // required!
  "workbench.preferredLightColorTheme": "Default Light+",
  "workbench.preferredDarkColorTheme": "Default Dark+",
  "sundial.interval": 20,
  "sundial.autoLocale": true
}
{
  "window.autoDetectColorScheme": false, // required!
  "workbench.preferredLightColorTheme": "Default Light+",
  "workbench.preferredDarkColorTheme": "Default Dark+",
  "sundial.sunrise": "05:12"
}
{
  "window.autoDetectColorScheme": false, // required!
  "workbench.preferredLightColorTheme": "Default Light+",
  "workbench.preferredDarkColorTheme": "Default Dark+",
  "sundial.dayVariable": 43,
  "sundial.latitude": "50.110924",
  "sundial.longitude": "8.682127",
  "sundial.daySettings": {
    "editor.fontSize": 13
  },
  "sundial.nightSettings": {
    "editor.fontSize": 15
  }
}

Development

We are working with webpack to bundle Sundial to the smallest possible size to increase the load time in VSCode.

  1. Install packages via (your preferred package manager) pnpm install
  2. Set sundial.debug to 2
  3. Run debugger => Launch Extension
    • View the Extension Host and adjust settings to test or
    • Change a file and save it, let webpack compile
  4. Commit your changes with a detailed explanation
  5. Create a pull request

Commits

Sundial follows this spec:

Releases

Run the below to create a new release. This will increase the version based on your changes and create a new CHANGELOG.md section.

pnpm run release
  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2019 Microsoft