23 lines
736 B
Lua
23 lines
736 B
Lua
|
|
local lang = jarvis.context.language
|
||
|
|
local helper = jarvis.context.command_path .. "\\_audio_devices.ps1"
|
||
|
|
local cmd = string.format(
|
||
|
|
'powershell -NoProfile -ExecutionPolicy Bypass -File "%s" -Action next',
|
||
|
|
helper
|
||
|
|
)
|
||
|
|
|
||
|
|
local res = jarvis.system.exec(cmd)
|
||
|
|
if not res.success then
|
||
|
|
jarvis.log("error", "next device failed: " .. tostring(res.stderr))
|
||
|
|
jarvis.audio.play_error()
|
||
|
|
return { chain = false }
|
||
|
|
end
|
||
|
|
|
||
|
|
local out = (res.stdout or ""):gsub("[\r\n]+$", "")
|
||
|
|
local name = out:match("^OK\t(.+)$") or out
|
||
|
|
|
||
|
|
local title = lang == "ru" and "Аудио переключено" or "Audio switched"
|
||
|
|
jarvis.system.notify(title, name)
|
||
|
|
jarvis.log("info", "audio switched to: " .. name)
|
||
|
|
jarvis.audio.play_ok()
|
||
|
|
return { chain = false }
|