(Demo) Windows 10 Dark Theme Switch


Windows 10 App Dark Theme Switch



The Windows 10 Dark Theme Switch is an utility and a demo at the same time. Utility because this small application allows to quickly enable or disable the dark theme for applications like the File Explorer, a feature introduced in Windows 10 version 1809 and higher. The dark theme can be enabled or disabled from Windows Settings, but and that’s the interesting point, it can be turned ON/OFF via the registry. And the nice thing with the registry technique, is that your version of Windows 10 doesn’t need to be activated…

Several functions (in Lua and Python) have been added in recent versions of GeeXLab to play with Windows registry:

 
The registry value that controls the dark theme is:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme

AppsUseLightTheme is a REG_DWORD value. If AppsUseLightTheme is equal to 1, the regular light theme is enabled. If AppsUseLightTheme is equal to 0, the light theme is disabled which means the dark theme is enabled!

With GeeXLab it’s easy to read the AppsUseLightTheme value. Here is a function in Lua that does the job:

function ReadDarkThemeState()
  local ret, x = gh_utils.win_registry_read_value_dword("HKEY_CURRENT_USER", "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme")
  if (ret == 1) then
    -- The registry value has been successfully read
    return 1-x -- if 0, dark theme is enabled!
  end
  return -1 -- error
end  

And here is the function that enables or disables the dark theme:

function EnableDarkTheme(state)
  gh_utils.win_registry_write_value_dword("HKEY_CURRENT_USER", "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "AppsUseLightTheme", 1-state)
end  

 
If you have Windows 10 v1809+, and if dark theme is not enabled, you should see this something like this when you launch GeeXLab dark theme switch the first time:

Windows 10 App Dark Theme Switch - Dark theme is disabled

 
This message means the value AppsUseLightTheme is nor present in the registry. If you click NO, GeeXLab does nothing. But if you click YES, GeeXLab creates the value in the registry. Once the value is created you should see something like:

Windows 10 App Dark Theme Switch - Dark theme is disabled

 
If you click on Enable Dark Theme, you should see:

Windows 10 App Dark Theme Switch - Dark theme is enabled

 
Yeah! You have enabled the dark theme!

Remark: this demo/app reads and writes in the registry. It’s recommended to backup your registry (using regedit > File > Export function) before playing with any tool that can modify the registry.

The source code of the demo (in Lua) is available in the src/ folder.

More information:





Leave a Comment

Your email address will not be published. Required fields are marked *