VS Code Theme Manager
🎨 Intelligent theme management for VS Code with automatic switching based on time, sunrise/sunset, and advanced logging capabilities.
✨ Features
- ⏰ Time-based Auto Switching: Automatically switch between light and dark themes based on configurable time schedules
- 🌅 Sunrise/Sunset Support: Switch themes based on natural light cycles with precise astronomical calculations
- 🎯 Manual Control: Quick toggle between themes with a single command
- 📊 Status Bar Integration: See current theme status, next switch time, and auto-switch state at a glance
- 🔍 Advanced Logging: Comprehensive English logging system with different levels (debug, info, warn, error)
- 🌍 Geographic Location Support: Automatic location detection for accurate sunrise/sunset calculations
- ⚙️ Flexible Configuration: Customize themes, switch times, cities, and UI behavior through VS Code settings
- 📈 Theme History: Track and review your theme switching history
- 🧪 Comprehensive Testing: Full test coverage with Vitest framework
🚀 Quick Start
- Install the extension
- The extension will automatically activate and show a welcome message on first use
- Choose your preferred auto-switch mode:
- Sunrise/Sunset Mode (default): Automatically detects your location and switches based on natural light
- Time Mode: Switch at specific times you configure
- Configure your preferences in VS Code settings (
themeManager.*
)
- Monitor theme status in the status bar
📋 Commands
Theme Manager: Toggle Theme
- Manually switch between light and dark themes
Theme Manager: Enable Auto Switch
- Enable automatic theme switching
Theme Manager: Disable Auto Switch
- Disable automatic theme switching
Theme Manager: Configure Switch Times
- Open time configuration dialog
Theme Manager: Show Theme History
- View your theme switching history
⚙️ Configuration
This extension contributes the following settings:
Auto Switch Settings
themeManager.autoSwitch.enabled
: Enable/disable automatic theme switching (default: true
)
themeManager.autoSwitch.mode
: Auto-switch mode - "time"
or "sunrise-sunset"
(default: "sunrise-sunset"
)
Theme Settings
themeManager.lightTheme
: Theme to use during light hours (default: "Default Light+"
)
themeManager.darkTheme
: Theme to use during dark hours (default: "Default Dark+"
)
Time Settings (for time mode)
themeManager.switchTime.light
: Time to switch to light theme in HH:MM format (default: "07:00"
)
themeManager.switchTime.dark
: Time to switch to dark theme in HH:MM format (default: "19:00"
)
Location Settings (for sunrise-sunset mode)
themeManager.location.city
: City for sunrise/sunset calculations (default: "北京"
)
- Supports major cities worldwide including Beijing, Shanghai, New York, London, Tokyo, etc.
UI Settings
themeManager.ui.showStatusBar
: Show theme manager in status bar (default: true
)
themeManager.ui.showNotifications
: Show notifications when themes are switched (default: true
)
themeManager.ui.statusBarFormat
: Status bar display format - "icon-only"
, "theme-name"
, or "full"
(default: "full"
)
🎯 Usage Examples
Example 1: Sunrise/Sunset Mode (Recommended)
{
"themeManager.autoSwitch.enabled": true,
"themeManager.autoSwitch.mode": "sunrise-sunset",
"themeManager.location.city": "New York",
"themeManager.lightTheme": "GitHub Light",
"themeManager.darkTheme": "GitHub Dark",
"themeManager.ui.showStatusBar": true,
"themeManager.ui.statusBarFormat": "full"
}
Example 2: Time-based Switching
{
"themeManager.autoSwitch.enabled": true,
"themeManager.autoSwitch.mode": "time",
"themeManager.switchTime.light": "08:00",
"themeManager.switchTime.dark": "18:00",
"themeManager.lightTheme": "Solarized Light",
"themeManager.darkTheme": "Solarized Dark"
}
Example 3: Minimal Setup with Notifications
{
"themeManager.autoSwitch.enabled": true,
"themeManager.ui.showNotifications": true,
"themeManager.ui.statusBarFormat": "icon-only"
}
Example 4: Night Owl Schedule
{
"themeManager.autoSwitch.enabled": true,
"themeManager.autoSwitch.mode": "time",
"themeManager.switchTime.light": "10:00",
"themeManager.switchTime.dark": "22:00",
"themeManager.lightTheme": "Light+ (default light)",
"themeManager.darkTheme": "Dark+ (default dark)"
}
🔧 How It Works
Sunrise/Sunset Mode
The extension uses precise astronomical calculations to determine sunrise and sunset times:
- Location Detection: Automatically detects your location or uses configured city
- Astronomical Calculations: Uses advanced algorithms for accurate sun times
- Polar Conditions: Handles extreme latitudes with intelligent fallback to time-based switching
- Daily Updates: Recalculates sun times daily to account for seasonal changes
Time-based Switching
For users who prefer fixed schedules:
- Smart Scheduling: Calculates next switch time based on current time and settings
- Periodic Monitoring: Runs background checks to ensure themes are applied correctly
- Edge Case Handling: Manages midnight crossover, system sleep/wake, and timezone changes
Intelligent Theme Management
- Theme Validation: Verifies theme availability before switching
- Graceful Fallbacks: Uses default themes if configured themes are unavailable
- History Tracking: Maintains a record of theme switches for debugging and user reference
- Performance Optimization: Efficient scheduling and minimal resource usage
- Status Bar Integration: Shows current theme and auto-switch status with visual indicators
- Manual Override: You can always manually toggle themes, which temporarily overrides automatic switching
📝 Requirements
- VS Code 1.102.0 or higher
- Internet connection for initial location detection (sunrise/sunset mode)
- No additional dependencies required
🌍 Supported Cities
The extension supports major cities worldwide for sunrise/sunset calculations:
Asia: Beijing, Shanghai, Tokyo, Seoul, Mumbai, Singapore, Bangkok, Jakarta
Europe: London, Paris, Berlin, Rome, Madrid, Amsterdam, Stockholm, Moscow
North America: New York, Los Angeles, Chicago, Toronto, Vancouver, Mexico City
Oceania: Sydney, Melbourne, Auckland
Others: São Paulo, Buenos Aires, Cairo, Johannesburg
Don't see your city? The extension will attempt to resolve any city name you provide.
🐛 Known Issues
- Initial location detection requires internet connection
- Theme switching might have a slight delay during VS Code startup
- Some custom themes may not be compatible with automatic switching
- Polar regions (extreme latitudes) fall back to time-based switching during polar night/day periods
🔧 Troubleshooting
Enable Debug Logging
- Open VS Code Developer Tools (
Help > Toggle Developer Tools
)
- Check the Console tab for detailed logs
- Look for messages prefixed with
[ThemeManager]
, [SunTimes]
, or [Logger]
Common Issues
- Themes not switching: Check if your configured themes are installed
- Location not detected: Verify internet connection and try setting a specific city
- Status bar not showing: Enable
themeManager.ui.showStatusBar
in settings
🚀 Roadmap
- [x] ✅ Sunrise/sunset calculation based on location
- [x] ✅ Advanced logging system
- [x] ✅ Comprehensive testing with Vitest
- [x] ✅ Status bar integration with multiple display formats
- [x] ✅ Theme history tracking
- [ ] 🔄 Multiple theme profiles and presets
- [ ] 🔄 Custom switching animations and transitions
- [ ] 🔄 Integration with weather data for cloud-aware switching
- [ ] 🔄 Advanced scheduling (weekday/weekend, seasonal adjustments)
- [ ] 🔄 Machine learning-based theme recommendations
- [ ] 🔄 Workspace-specific theme configurations
- [ ] 🔄 Theme synchronization across devices
📄 Release Notes
0.0.1
- Initial release
- Basic time-based theme switching
- System theme following support
- Status bar integration
- Configuration through VS Code settings
🤝 Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
📜 License
This extension is licensed under the MIT License.
Enjoy coding with the perfect theme for every moment! 🎨