lambdalisue/vim-chameleon

Support Windows

Open

#1 opened on Nov 19, 2024

View on GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (0 forks)github user discovery
enhancementgood first issue

Repository metrics

Stars
 (10 stars)
PR merge metrics
 (PR metrics pending)

Description

It seems we can use reg query command to to access the registry to find if the application is in dark mode or not.

Detecting if an Application is in Dark Mode in Windows via CLI

Steps:

The registry path for the dark mode setting is:

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

The value to check is:

  • AppsUseLightTheme (DWORD)

If AppsUseLightTheme is 0, the application/system is in dark mode.
If AppsUseLightTheme is 1, the application/system is in light mode.


CLI Command

You can use the following command to check the value:

reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v AppsUseLightTheme

Output Example

  • Dark Mode:

    AppsUseLightTheme    REG_DWORD    0x0
    
  • Light Mode:

    AppsUseLightTheme    REG_DWORD    0x1
    

Parse the Result in Scripts

Batch Script Example:

for /f "tokens=3" %%A in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v AppsUseLightTheme') do (
    if %%A==0x0 (
        echo Dark mode is enabled.
    ) else (
        echo Light mode is enabled.
    )
)

PowerShell Script Example:

$regValue = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme"
if ($regValue.AppsUseLightTheme -eq 0) {
    Write-Output "Dark mode is enabled."
} else {
    Write-Output "Light mode is enabled."
}

Contributor guide