#!/usr/bin/env python3 """Test-only system adapter. Never executes commands or accesses system buses.""" import json,os,sys from pathlib import Path base=Path(os.environ['GLASSMXRPH_SYSTEM_EVENTS']);saved=base.with_suffix('.state.json') default={'brightness':{'available':True,'value':40,'devices':[]},'nightLight':{'available':True,'enabled':False},'dnd':{'available':True,'enabled':False},'profiles':{'available':True,'current':'balanced','profiles':['power-saver','balanced','performance']},'power':{'available':True,'lock':True,'logout':True,'suspend':True,'reboot':True,'shutdown':True}} state=json.loads(saved.read_text()) if saved.exists() else default req=json.loads(sys.argv[1]) if req['op']=='action' and base.with_suffix('.fail').exists(): print(json.dumps({'ok':False,'error':'Synthetic provider failure'}));sys.exit(1) if req['op']=='action': with base.open('a') as f:f.write(json.dumps(req)+'\n') kind=req['action'];value=req.get('value') if kind in ['nightLight','dnd']:state[kind]['enabled']=value elif kind=='brightness':state[kind]['value']=value elif kind=='profile':state['profiles']['current']=value saved.write_text(json.dumps(state)) print(json.dumps({'ok':True,'state':state}))