Thing/scripts/capture-eve-screenshot.ps1

46 lines
1.5 KiB
PowerShell
Raw Normal View History

2026-06-02 16:59:51 +01:00
param(
[string] $Target = "eve",
2026-06-05 19:03:29 +01:00
[string] $OutputDirectory = "artifacts\screenshots",
[string] $BundleId = "org.gamecult.evecanvas",
[string] $FixturePath = ""
2026-06-02 16:59:51 +01:00
)
$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
2026-06-05 19:03:29 +01:00
$outputRoot = if ([System.IO.Path]::IsPathRooted($OutputDirectory)) {
$OutputDirectory
} else {
Join-Path $projectRoot $OutputDirectory
}
2026-06-02 16:59:51 +01:00
New-Item -ItemType Directory -Force -Path $outputRoot | Out-Null
$stamp = Get-Date -Format "yyyyMMdd-HHmmss"
$localPath = Join-Path $outputRoot "eve-$stamp.png"
$remoteDir = "/var/mobile/Library/EveCanvas"
$remotePath = "$remoteDir/latest-screenshot.png"
$requestPath = "$remoteDir/capture-request"
$remoteFixturePath = "$remoteDir/current-surface.json"
2026-06-02 16:59:51 +01:00
2026-06-05 19:03:29 +01:00
ssh $Target "uiopen --bundleid '$BundleId' >/dev/null 2>&1 || true"
Start-Sleep -Seconds 1
ssh $Target "mkdir -p '$remoteDir' && chown mobile:mobile '$remoteDir' && rm -f '$remotePath' '$requestPath' && chown mobile:mobile '$remoteDir' 2>/dev/null || true"
if ($FixturePath) {
scp $FixturePath "${Target}:$remoteFixturePath" | Out-Host
} else {
ssh $Target "rm -f '$remoteFixturePath'"
}
ssh $Target "touch '$requestPath' && chown mobile:mobile '$requestPath' 2>/dev/null || true"
2026-06-02 16:59:51 +01:00
$deadline = (Get-Date).AddSeconds(10)
do {
Start-Sleep -Milliseconds 250
ssh $Target "test -s '$remotePath'"
if ($LASTEXITCODE -eq 0) {
scp "${Target}:$remotePath" $localPath
Write-Host $localPath
exit 0
}
} while ((Get-Date) -lt $deadline)
throw "Timed out waiting for EveCanvas screenshot at ${Target}:$remotePath"