AkurAI Build
Menu

cosmic-mobile

public

Latest change c6ad13a254dbbd666c52d33c7a025924962d6839 - Add emulator control client by AkurAI Build

#!/usr/bin/env python3
"""Use the isolated guest IPC bridge; no network or credentials."""
import json
import sys
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parent / 'runtime/captures'
def call(action, arg=''):
    assert action in {'windows','home','overview','close','focus','spawn','shot'}
    assert not arg or arg.replace('-','').isalnum()
    (ROOT/'done').unlink(missing_ok=True)
    (ROOT/'request.tmp').write_text(f'{action} {arg}\n')
    (ROOT/'request.tmp').rename(ROOT/'request')
    end = time.monotonic()+15
    while not (ROOT/'done').exists():
        if time.monotonic()>end: raise TimeoutError('Guest control timed out')
        time.sleep(.1)
    if action=='windows': return json.loads((ROOT/'windows.json').read_text())
if __name__=='__main__':
    print(call(*sys.argv[1:]))