Batch HyprGlass option reads
The HyprGlass helper read each option with its own hyprctl process: about 40 at startup and on every Hyprland config reload. Reads now go through one `hyprctl -j --batch` call; writes are still verified one by one. Startup goes from 43 hyprctl calls to 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9aa61559eb
commit
0e43c47bbb
2 files changed
+21
-6
No files matched your search
+3
-3
@@ -12,14 +12,14 @@ class GlassTests(unittest.TestCase):
|
||||
self.state=self.original.copy()
|
||||
def fake_put(self,key,value):self.state[key]=value
|
||||
def test_apply_restore_preserves_other_rules(self):
|
||||
with tempfile.TemporaryDirectory() as temp,patch.dict(os.environ,{'XDG_STATE_HOME':temp,'HYPRLAND_INSTANCE_SIGNATURE':'fixture'}),patch.object(glass,'get',lambda k:self.state[k]),patch.object(glass,'put',self.fake_put):
|
||||
with tempfile.TemporaryDirectory() as temp,patch.dict(os.environ,{'XDG_STATE_HOME':temp,'HYPRLAND_INSTANCE_SIGNATURE':'fixture'}),patch.object(glass,'get',lambda k:self.state[k]),patch.object(glass,'get_many',lambda keys:{k:self.state[k] for k in keys}),patch.object(glass,'put',self.fake_put):
|
||||
self.assertTrue(glass.dispatch({'action':'apply','options':self.options})['available'])
|
||||
self.assertEqual(self.state['default_preset'],'default')
|
||||
self.assertEqual(self.state['layers:namespaces'],'other-shell')
|
||||
glass.dispatch({'action':'restore'})
|
||||
self.assertEqual(self.state,self.original)
|
||||
def test_restore_keeps_external_changes(self):
|
||||
with tempfile.TemporaryDirectory() as temp,patch.dict(os.environ,{'XDG_STATE_HOME':temp,'HYPRLAND_INSTANCE_SIGNATURE':'fixture'}),patch.object(glass,'get',lambda k:self.state[k]),patch.object(glass,'put',self.fake_put):
|
||||
with tempfile.TemporaryDirectory() as temp,patch.dict(os.environ,{'XDG_STATE_HOME':temp,'HYPRLAND_INSTANCE_SIGNATURE':'fixture'}),patch.object(glass,'get',lambda k:self.state[k]),patch.object(glass,'get_many',lambda keys:{k:self.state[k] for k in keys}),patch.object(glass,'put',self.fake_put):
|
||||
glass.dispatch({'action':'apply','options':self.options})
|
||||
self.state['default_preset']='external'
|
||||
result=glass.dispatch({'action':'restore'})
|
||||
@@ -28,7 +28,7 @@ class GlassTests(unittest.TestCase):
|
||||
def fail(key,value):
|
||||
if key=='dark:brightness' and value!=self.original[key]:raise ValueError('fixture failure')
|
||||
self.fake_put(key,value)
|
||||
with tempfile.TemporaryDirectory() as temp,patch.dict(os.environ,{'XDG_STATE_HOME':temp,'HYPRLAND_INSTANCE_SIGNATURE':'fixture'}),patch.object(glass,'get',lambda k:self.state[k]),patch.object(glass,'put',fail):
|
||||
with tempfile.TemporaryDirectory() as temp,patch.dict(os.environ,{'XDG_STATE_HOME':temp,'HYPRLAND_INSTANCE_SIGNATURE':'fixture'}),patch.object(glass,'get',lambda k:self.state[k]),patch.object(glass,'get_many',lambda keys:{k:self.state[k] for k in keys}),patch.object(glass,'put',fail):
|
||||
with self.assertRaises(ValueError):glass.dispatch({'action':'apply','options':self.options})
|
||||
self.assertEqual(self.state,self.original)
|
||||
def test_validation_before_writes(self):
|
||||
|
||||
Reference in new issue
Block a user