J.A.R.V.I.S-rust/resources/commands/media/next_track.lua

14 lines
403 B
Lua
Raw Normal View History

feat(commands): add media controls + system info packs media/ — play_pause, next, prev, stop via user32!keybd_event (VK_MEDIA_* 0xB0..0xB3). Helper _media_helper.ps1 mirrors the volume/ pack pattern, so the same C# P/Invoke style works for the four standard media keys without needing any external tooling. Catches Spotify, foobar, browsers, Yandex Music PWA — anything that responds to system media keys. sysinfo/ — battery / time / cpu / ram / disk and an "all" combo. _sysinfo.ps1 uses CIM queries (Win32_Battery, Win32_OperatingSystem, Win32_LogicalDisk, Win32_Processor + Win32_PerfFormattedData_PerfOS_ Processor) — no external deps. Time is rendered in ru-RU culture ("01:17, 15 мая, пятница"). Battery falls back to a friendly "no battery, looks like a desktop" when Win32_Battery is empty. SystemDrive env var resolves the right disk on non-C:/ installs. Each sysinfo command notifies the line as a Windows toast and logs it. Triggered locally: sysinfo_all currently reports: Сейчас: 01:17, 15 мая, пятница Батарея не обнаружена (видимо, десктоп) CPU: AMD Ryzen 7 5700X3D 8-Core Processor, загрузка 4% RAM: 23.4 из 47.9 ГБ (49% занято) Диск C:: свободно 118.2 из 1906.8 ГБ Total command packs is now 9 (verified via jarvis-gui startup log). Portability: all PowerShell helpers use $env:SystemDrive and CIM classes that ship with every Windows install; Lua wrappers resolve the helper path via jarvis.context.command_path (no hardcoded user profile paths or absolute C:\ refs). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 01:19:30 +03:00
local helper = jarvis.context.command_path .. "\\_media_helper.ps1"
local cmd = string.format(
'powershell -NoProfile -ExecutionPolicy Bypass -File "%s" -Action next',
helper
)
local res = jarvis.system.exec(cmd)
if res.success then
jarvis.audio.play_ok()
else
jarvis.log("error", "media next failed: " .. tostring(res.stderr))
jarvis.audio.play_error()
end
return { chain = false }