Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher, settings, Control Center, dashboard, OSD, lock screen, desktop widgets, plugin host with the vendored Noctalia/Omarchy compatibility layer, helpers, packaging, tests and phase documentation. Includes the optimization work so far: usage widgets and dashboard gauges no longer animate continuously, desktop widgets pause while covered, system controls stop flickering on background polls, dock app matching uses an indexed catalog, and workspace ghosts are created only for occupied slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
99e64a7713
433 files changed
+57792
No files matched your search
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Global HyprGlass controls using verified live scalar options, with a restore journal."""
|
||||
import json,math,os,subprocess,sys
|
||||
from pathlib import Path
|
||||
|
||||
PREFIX='plugin:hyprglass:'
|
||||
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)}
|
||||
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,
|
||||
'contrast':1,'saturation':1,'vibrancy':.15,'adaptive_dim':.2}
|
||||
|
||||
|
||||
def run(args):
|
||||
p=subprocess.run(['hyprctl',*args],text=True,capture_output=True,timeout=4)
|
||||
if p.returncode:raise ValueError((p.stderr or p.stdout).strip()[:350])
|
||||
return p.stdout.strip()
|
||||
|
||||
def get(key):
|
||||
data=json.loads(run(['-j','getoption',PREFIX+key]))
|
||||
for field in ['str','int','float']:
|
||||
if field in data:return data[field]
|
||||
raise ValueError('HyprGlass option unavailable: '+key)
|
||||
|
||||
def put(key,value):
|
||||
result=run(['keyword',PREFIX+key,str(value)])
|
||||
if result!='ok':raise ValueError(result[:350])
|
||||
if get(key)!=value:raise ValueError('HyprGlass did not accept '+key)
|
||||
|
||||
def values(options):
|
||||
controls=options.get('values',{})
|
||||
if set(controls)!=set(RANGES):raise ValueError('Incomplete glass settings')
|
||||
for key,(low,high) in RANGES.items():
|
||||
v=controls[key]
|
||||
if type(v) not in (int,float) or not math.isfinite(v) or not low<=v<=high:raise ValueError('Invalid '+key)
|
||||
if not float(controls['blur_iterations']).is_integer():raise ValueError('Blur passes must be an integer')
|
||||
if type(options.get('layers')) is not bool or type(options.get('effectEnabled',True)) is not bool:raise ValueError('Invalid glass toggle')
|
||||
# "default" is the plugin's documented fallback: custom presets otherwise
|
||||
# override scalar sliders, and live preset definitions are only committed at reload.
|
||||
result={}
|
||||
for key,v in controls.items():
|
||||
result['dark:'+key]=v
|
||||
result['light:'+key]=v
|
||||
result.update({'dark:tint_color':0xffffff08,'light:tint_color':0xffffff08,
|
||||
'dark:glass_opacity':1,'light:glass_opacity':1,
|
||||
'default_preset':'default','default_theme':'dark','layers:preset':'default','layers:mask_mode':'alpha',
|
||||
'layers:enabled':int(options['layers'] and options.get('effectEnabled',True)),'enabled':int(options.get('effectEnabled',True))})
|
||||
return result
|
||||
|
||||
def journal_path():
|
||||
return Path(os.environ.get('XDG_STATE_HOME',Path.home()/'.local/state'))/'glassMxrph/glass-restore.json'
|
||||
|
||||
def save(path,data):
|
||||
path.parent.mkdir(parents=True,exist_ok=True)
|
||||
temp=path.with_suffix('.tmp');temp.write_text(json.dumps(data));temp.replace(path)
|
||||
|
||||
def probe():
|
||||
try:
|
||||
return dict(available=True,preset=get('default_preset'),enabled=bool(get('enabled')),layers=bool(get('layers:enabled')),
|
||||
namespaces=get('layers:namespaces'),exclusions=get('layers:exclude_namespaces'),overrides=get('layers:namespace_presets'))
|
||||
except (OSError,ValueError,subprocess.TimeoutExpired):return dict(available=False)
|
||||
|
||||
def dispatch(req):
|
||||
action=req.get('action')
|
||||
if action=='probe':return probe()
|
||||
path=journal_path();session=os.environ.get('HYPRLAND_INSTANCE_SIGNATURE','')
|
||||
journal=json.loads(path.read_text()) if path.exists() else {}
|
||||
if journal.get('session')!=session or req.get('reloaded'):journal={}
|
||||
if action=='restore':
|
||||
skipped=[]
|
||||
for key,old in reversed(list(journal.get('before',{}).items())):
|
||||
if get(key)==journal['after'].get(key):put(key,old)
|
||||
else:skipped.append(key)
|
||||
path.unlink(missing_ok=True)
|
||||
return dict(**probe(),notice='Restored previous glass settings.' if not skipped else 'Preserved externally changed options: '+', '.join(skipped))
|
||||
if action!='apply':raise ValueError('Unknown glass request')
|
||||
target=values(req['options'])
|
||||
current={key:get(key) for key in target}
|
||||
before=journal.get('before',current)
|
||||
# Persist before writing so a partial operation can be restored after a crash.
|
||||
record=dict(session=session,before=before,after=target)
|
||||
save(path,record)
|
||||
changed=[]
|
||||
try:
|
||||
for key,value in target.items():
|
||||
if current[key]!=value:
|
||||
changed.append(key);put(key,value)
|
||||
except Exception:
|
||||
rollback_failed=False
|
||||
for key in reversed(changed):
|
||||
try:put(key,current[key])
|
||||
except Exception:rollback_failed=True
|
||||
if not rollback_failed:
|
||||
if journal:save(path,journal)
|
||||
else:path.unlink(missing_ok=True)
|
||||
raise
|
||||
return dict(**probe(),notice='Global glass applied. Explicit per-application and per-layer preset rules still take priority.')
|
||||
|
||||
if __name__=='__main__':
|
||||
try:print(json.dumps(dict(ok=True,**dispatch(json.loads(sys.argv[1])))))
|
||||
except (OSError,ValueError,KeyError,subprocess.TimeoutExpired) as e:print(json.dumps(dict(ok=False,error=str(e))))
|
||||
Reference in new issue
Block a user