J.A.R.V.I.S-rust/resources/commands/media/_media_helper.ps1
Bossiara13 8c8c13167b 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

20 lines
559 B
PowerShell

param(
[Parameter(Mandatory=$true)]
[ValidateSet("play_pause","next","prev","stop")]
[string]$Action
)
Add-Type -Name MediaKey -Namespace Win32 -MemberDefinition @'
[DllImport("user32.dll")]
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, System.UIntPtr dwExtraInfo);
'@
$vk = switch ($Action) {
"play_pause" { 0xB3 }
"next" { 0xB0 }
"prev" { 0xB1 }
"stop" { 0xB2 }
}
[Win32.MediaKey]::keybd_event($vk, 0, 0, [UIntPtr]::Zero)
[Win32.MediaKey]::keybd_event($vk, 0, 2, [UIntPtr]::Zero)