51 lines
1.9 KiB
Lua
51 lines
1.9 KiB
Lua
|
|
-- Leave focus mode — undo the three side-effects of focus.start.
|
||
|
|
|
||
|
|
local lang = jarvis.context.language
|
||
|
|
local report = {}
|
||
|
|
|
||
|
|
-- 1) Revert profile to default
|
||
|
|
local ok1 = pcall(function() jarvis.profile.set("default") end)
|
||
|
|
if ok1 then
|
||
|
|
table.insert(report, lang == "ru" and "обычный профиль" or "default profile")
|
||
|
|
end
|
||
|
|
|
||
|
|
-- 2) Re-enable notifications via the same registry key
|
||
|
|
local ps = [[
|
||
|
|
$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.QuietHours'
|
||
|
|
if (Test-Path $key) {
|
||
|
|
Set-ItemProperty -Path $key -Name 'NOC_GLOBAL_SETTING_TOASTS_ENABLED' -Value 1 -Type DWord
|
||
|
|
}
|
||
|
|
Write-Output 'fa-off'
|
||
|
|
]]
|
||
|
|
local cmd = 'powershell -NoProfile -ExecutionPolicy Bypass -Command "& {'
|
||
|
|
.. ps:gsub('\r?\n', '; '):gsub('"', '\\"')
|
||
|
|
.. '}"'
|
||
|
|
local res = jarvis.system.exec(cmd)
|
||
|
|
if res.success then
|
||
|
|
table.insert(report, lang == "ru" and "уведомления включены" or "notifications restored")
|
||
|
|
end
|
||
|
|
|
||
|
|
-- 3) Cancel any pending stretch reminders we created — match by name
|
||
|
|
-- (scheduler has no native "tags" so we use the human name we set in start.lua)
|
||
|
|
local cancelled = 0
|
||
|
|
local target_names = { "Стретч-пауза", "Stretch break" }
|
||
|
|
for _, task in ipairs(jarvis.scheduler.list()) do
|
||
|
|
for _, name in ipairs(target_names) do
|
||
|
|
if task.name == name then
|
||
|
|
jarvis.scheduler.remove(task.id)
|
||
|
|
cancelled = cancelled + 1
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
if cancelled > 0 then
|
||
|
|
table.insert(report, string.format(lang == "ru"
|
||
|
|
and "отменил %d напоминаний"
|
||
|
|
or "cancelled %d reminders", cancelled))
|
||
|
|
end
|
||
|
|
|
||
|
|
local summary = #report > 0 and table.concat(report, ", ")
|
||
|
|
or (lang == "ru" and "ничего не было активно" or "nothing was active")
|
||
|
|
return jarvis.cmd.ok(lang == "ru"
|
||
|
|
and ("Фокус выключен: " .. summary .. ".")
|
||
|
|
or ("Focus mode off: " .. summary .. "."))
|