You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Name: Toggle System Theme// Author: arkatsy// Description: Toggles the system theme between light and dark mode.import"@johnlindquist/kit";import*as_regeditfrom"regedit";import{exec}from"child_process";constregedit=_regedit.promisified;constREGISTRY_PATH="HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";constDARK_THEME_VALUE=0;constLIGHT_THEME_VALUE=1;typeSettingValue={type: string;value: typeofDARK_THEME_VALUE|typeofLIGHT_THEME_VALUE;};typeRegistryThemeKeys={AppsUseLightTheme: SettingValue;SystemUsesLightTheme: SettingValue;};constres=awaitregedit.list([REGISTRY_PATH]);constsettingValues=res[REGISTRY_PATH].values;if(!("AppsUseLightTheme"insettingValues)||!("SystemUsesLightTheme"insettingValues)){thrownewError("AppsUseLightTheme or SystemUsesLightTheme not found in registry");}constisDark=(settingValuesasRegistryThemeKeys).AppsUseLightTheme.value===DARK_THEME_VALUE;constnextThemeValue=isDark ? LIGHT_THEME_VALUE : DARK_THEME_VALUE;awaitregedit.putValue({[REGISTRY_PATH]: {AppsUseLightTheme: {type: "REG_DWORD",value: nextThemeValue,},SystemUsesLightTheme: {type: "REG_DWORD",value: nextThemeValue,},},});// When SystemUsesLightTheme changes, some elements like the taskbar need to be restarted for the theme to apply properly.exec("taskkill /F /IM explorer.exe",(error)=>{if(error){thrownewError(`Failed to kill explorer.exe: ${error.message}`);}exec("start explorer.exe",(error)=>{if(error){thrownewError(`Failed to restart explorer.exe: ${error.message}`);}});});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Beta Was this translation helpful? Give feedback.
All reactions