27 lines
1 KiB
Lua
27 lines
1 KiB
Lua
|
|
local cmd_id = jarvis.context.command_id
|
||
|
|
local lang = jarvis.context.language
|
||
|
|
local is_light = (cmd_id == "theme_light")
|
||
|
|
local value = is_light and 1 or 0
|
||
|
|
|
||
|
|
local key = [[HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize]]
|
||
|
|
local ps = string.format(
|
||
|
|
"Set-ItemProperty -Path 'Registry::%s' -Name AppsUseLightTheme -Value %d -Type DWord; "
|
||
|
|
.. "Set-ItemProperty -Path 'Registry::%s' -Name SystemUsesLightTheme -Value %d -Type DWord",
|
||
|
|
key, value, key, value
|
||
|
|
)
|
||
|
|
local res = jarvis.system.exec(string.format('powershell -NoProfile -Command "%s"', ps:gsub('"', '\\"')))
|
||
|
|
|
||
|
|
if res.success then
|
||
|
|
jarvis.system.notify(
|
||
|
|
lang == "ru" and "Тема" or "Theme",
|
||
|
|
is_light and (lang == "ru" and "Светлая включена" or "Light enabled")
|
||
|
|
or (lang == "ru" and "Тёмная включена" or "Dark enabled")
|
||
|
|
)
|
||
|
|
jarvis.audio.play_ok()
|
||
|
|
else
|
||
|
|
jarvis.log("error", "theme set failed: " .. tostring(res.stderr))
|
||
|
|
jarvis.audio.play_error()
|
||
|
|
end
|
||
|
|
|
||
|
|
return { chain = false }
|