From 83a0d155ba9fe6272cfe512325d94060af828a39 Mon Sep 17 00:00:00 2001 From: mx Date: Wed, 7 Oct 2026 22:59:52 +0200 Subject: [PATCH] Support batched reads in the glass test's recording hyprctl The customization runtime test's fake hyprctl did not understand `--batch`, so batched HyprGlass reads fell through to the real compositor (writes were still recorded). It now answers batched getoption requests from the record. The glass probe reports why HyprGlass is unavailable. Co-Authored-By: Claude Opus 5.5 --- quickshell/helpers/glass.py | 2 +- tests/customization_runtime.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/quickshell/helpers/glass.py b/quickshell/helpers/glass.py index daf7a45..f3ed1b7 100644 --- a/quickshell/helpers/glass.py +++ b/quickshell/helpers/glass.py @@ -76,7 +76,7 @@ def probe(): o=get_many(['default_preset','enabled','layers:enabled','layers:namespaces','layers:exclude_namespaces','layers:namespace_presets']) return dict(available=True,preset=o['default_preset'],enabled=bool(o['enabled']),layers=bool(o['layers:enabled']), namespaces=o['layers:namespaces'],exclusions=o['layers:exclude_namespaces'],overrides=o['layers:namespace_presets']) - except (OSError,ValueError,subprocess.TimeoutExpired):return dict(available=False) + except (OSError,ValueError,subprocess.TimeoutExpired) as error:return dict(available=False,reason=str(error)[:200]) def dispatch(req): action=req.get('action') diff --git a/tests/customization_runtime.py b/tests/customization_runtime.py index a34b880..3386585 100644 --- a/tests/customization_runtime.py +++ b/tests/customization_runtime.py @@ -32,8 +32,13 @@ with tempfile.TemporaryDirectory(prefix='glassmxrph-customization-') as tmp: import json,os,subprocess,sys from pathlib import Path args=sys.argv[1:];p=Path(os.environ['GLASS_TEST_RECORD']);d=json.loads(p.read_text()) -if 'getoption' in args and args[-1].startswith('plugin:hyprglass:'): - k=args[-1].removeprefix('plugin:hyprglass:');v=d[k];print(json.dumps({'str' if isinstance(v,str) else 'float' if isinstance(v,float) else 'int':v,'set':True})) +def option(name): + k=name.removeprefix('plugin:hyprglass:');v=d[k] + return json.dumps({'option':name,'str' if isinstance(v,str) else 'float' if isinstance(v,float) else 'int':v,'set':True}) +if '--batch' in args and all(c.strip().startswith('getoption plugin:hyprglass:') for c in args[-1].split(';')): + print('\\n\\n'.join(option(c.split()[1]) for c in args[-1].split(';'))) +elif 'getoption' in args and args[-1].startswith('plugin:hyprglass:'): + print(option(args[-1])) elif args[0]=='keyword' and args[1].startswith('plugin:hyprglass:'): k=args[1].removeprefix('plugin:hyprglass:');v=args[2] if not isinstance(d[k],str):v=float(v);v=int(v) if v.is_integer() else v