Use Lua dispatches and options for Hyprland 0.57
Hyprland 0.57 removed hyprctl keyword and name-style dispatches, and hyprglass 1.1 dropped its layer namespace options. Move workspace, window, logout, glass and Game Mode calls to hl.dsp and hyprctl eval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bfbfc8961e
commit
c716a20e04
6 files changed
+31
-13
No files matched your search
@@ -8,6 +8,7 @@ RANGES={'blur_strength':(0,5),'blur_iterations':(1,5),'refraction_strength':(0,8
|
||||
'chromatic_aberration':(0,1),'fresnel_strength':(0,1),'specular_strength':(0,1),
|
||||
'edge_thickness':(0,.15),'lens_distortion':(0,1),'brightness':(.2,2),
|
||||
'contrast':(.2,2),'saturation':(0,2),'vibrancy':(0,1),'adaptive_dim':(0,1)}
|
||||
BOOLS={'enabled','layers:enabled'}
|
||||
GHOSTTY={'blur_strength':.45,'blur_iterations':2,'refraction_strength':3,
|
||||
'chromatic_aberration':.45,'fresnel_strength':.5,'specular_strength':.8,
|
||||
'edge_thickness':.065,'lens_distortion':.25,'brightness':.95,
|
||||
@@ -21,8 +22,8 @@ def run(args):
|
||||
|
||||
def get(key):
|
||||
data=json.loads(run(['-j','getoption',PREFIX+key]))
|
||||
for field in ['str','int','float']:
|
||||
if field in data:return data[field]
|
||||
for field in ['str','int','float','bool']:
|
||||
if field in data:return int(data[field]) if field=='bool' else data[field]
|
||||
raise ValueError('HyprGlass option unavailable: '+key)
|
||||
|
||||
def get_many(keys):
|
||||
@@ -33,14 +34,23 @@ def get_many(keys):
|
||||
while pos<len(out) and out[pos].isspace():pos+=1
|
||||
if pos>=len(out):break
|
||||
data,pos=decoder.raw_decode(out,pos)
|
||||
value=next((data[f] for f in ['str','int','float'] if f in data),None)
|
||||
value=next((data[f] for f in ['str','int','float','bool'] if f in data),None)
|
||||
if isinstance(value,bool):value=int(value)
|
||||
if value is not None:found[str(data.get('option','')).removeprefix(PREFIX)]=value
|
||||
missing=[k for k in keys if k not in found]
|
||||
if missing:raise ValueError('HyprGlass option unavailable: '+missing[0])
|
||||
return found
|
||||
|
||||
def lua_table(key,value):
|
||||
# "dark:brightness" -> { dark = { brightness = 0.9 } }
|
||||
if key in BOOLS:text='true' if value else 'false'
|
||||
elif isinstance(value,str):text="'"+value+"'"
|
||||
else:text=repr(value)
|
||||
for part in reversed(key.split(':')):text='{ '+part+' = '+text+' }'
|
||||
return text
|
||||
|
||||
def put(key,value):
|
||||
result=run(['keyword',PREFIX+key,str(value)])
|
||||
result=run(['eval','hl.plugin.hyprglass.config('+lua_table(key,value)+')'])
|
||||
if result!='ok':raise ValueError(result[:350])
|
||||
if get(key)!=value:raise ValueError('HyprGlass did not accept '+key)
|
||||
|
||||
@@ -73,9 +83,9 @@ def save(path,data):
|
||||
|
||||
def probe():
|
||||
try:
|
||||
o=get_many(['default_preset','enabled','layers:enabled','layers:namespaces','layers:exclude_namespaces','layers:namespace_presets'])
|
||||
o=get_many(['default_preset','enabled','layers:enabled'])
|
||||
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'])
|
||||
namespaces='',exclusions='',overrides='')
|
||||
except (OSError,ValueError,subprocess.TimeoutExpired) as error:return dict(available=False,reason=str(error)[:200])
|
||||
|
||||
def dispatch(req):
|
||||
|
||||
Reference in new issue
Block a user