diff --git a/quickshell/bar/modules/WorkspacesModule.qml b/quickshell/bar/modules/WorkspacesModule.qml index c62131b..2cabcfb 100644 --- a/quickshell/bar/modules/WorkspacesModule.qml +++ b/quickshell/bar/modules/WorkspacesModule.qml @@ -199,7 +199,7 @@ GlassPill { anchors.fill: parent hoverEnabled: root.pacman cursorShape: Qt.PointingHandCursor - onClicked: Hyprland.dispatch("workspace " + (slot.index + 1)) + onClicked: Hyprland.dispatch("hl.dsp.focus({ workspace = '" + (slot.index + 1) + "' })") } } } diff --git a/quickshell/compat/noctalia/Services/Compositor/CompositorService.qml b/quickshell/compat/noctalia/Services/Compositor/CompositorService.qml index 3cee374..950eb2e 100644 --- a/quickshell/compat/noctalia/Services/Compositor/CompositorService.qml +++ b/quickshell/compat/noctalia/Services/Compositor/CompositorService.qml @@ -26,6 +26,6 @@ Singleton { return s ? s.devicePixelRatio : 1; } function switchToWorkspace(workspace) { - Hyprland.dispatch("workspace " + (workspace && workspace.id !== undefined ? workspace.id : workspace)); + Hyprland.dispatch("hl.dsp.focus({ workspace = '" + (workspace && workspace.id !== undefined ? workspace.id : workspace) + "' })"); } } diff --git a/quickshell/helpers/gamemode.py b/quickshell/helpers/gamemode.py index a137ec6..1e44216 100644 --- a/quickshell/helpers/gamemode.py +++ b/quickshell/helpers/gamemode.py @@ -27,12 +27,20 @@ def get_many(keys): nxt=out.find('{',pos+1) if nxt<0:break pos=nxt;continue - if isinstance(data,dict) and 'int' in data:found[str(data.get('option',''))]=data['int'] + if isinstance(data,dict) and ('int' in data or 'bool' in data):found[str(data.get('option',''))]=int(data.get('int',data.get('bool'))) return {k:found[k] for k in keys if k in found} +def lua_set(key,value): + # "decoration:blur:enabled" -> hl.config({ decoration = { blur = { enabled = false } } }) + path=key.split(':');text='true' if value else 'false' + target='hl.config(' + if path[0]=='plugin':target='hl.plugin.%s.config('%path[1];path=path[2:] + for part in reversed(path):text='{ '+part+' = '+text+' }' + return target+text+')' + def put_many(values): if not values:return - out=run(['--batch',';'.join('keyword %s %d'%(k,v) for k,v in values.items())]) + out=run(['--batch',';'.join('eval '+lua_set(k,v) for k,v in values.items())]) bad=[line for line in out.splitlines() if line.strip() and line.strip()!='ok'] if bad:raise ValueError(bad[0][:350]) diff --git a/quickshell/helpers/glass.py b/quickshell/helpers/glass.py index f3ed1b7..e367370 100644 --- a/quickshell/helpers/glass.py +++ b/quickshell/helpers/glass.py @@ -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):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): diff --git a/quickshell/helpers/system.py b/quickshell/helpers/system.py index 1b1526d..6c6e6d8 100644 --- a/quickshell/helpers/system.py +++ b/quickshell/helpers/system.py @@ -129,7 +129,7 @@ def action(req): if value in ['logout','reboot','shutdown'] and req.get('confirmed') is not True:raise ValueError('Explicit confirmation required') if not power(options['power']).get(value):raise ValueError('Power action unavailable') if value=='lock':subprocess.Popen(lock_command(options['power']),stdin=subprocess.DEVNULL,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,start_new_session=True) - elif value=='logout':run(['hyprctl','dispatch','exit']) + elif value=='logout':run(['hyprctl','dispatch','hl.dsp.exit()']) else:run(['busctl','--system','--auto-start=no','--timeout=10','call','org.freedesktop.login1','/org/freedesktop/login1','org.freedesktop.login1.Manager',{'suspend':'Suspend','reboot':'Reboot','shutdown':'PowerOff'}[value],'b','true'],15) elif kind=='manager': executable={'network':'nm-connection-editor','bluetooth':'blueman-manager'}.get(value) diff --git a/quickshell/services/HyprlandService.qml b/quickshell/services/HyprlandService.qml index 6283fa7..9c4ae8a 100644 --- a/quickshell/services/HyprlandService.qml +++ b/quickshell/services/HyprlandService.qml @@ -44,7 +44,7 @@ Singleton { if (window.handle) window.handle.activate(); else if (/^(0x)?[0-9a-f]+$/i.test(address)) - Hyprland.dispatch("focuswindow address:" + (address.startsWith("0x") ? address : "0x" + address)); + Hyprland.dispatch("hl.dsp.focus({ window = 'address:" + (address.startsWith("0x") ? address : "0x" + address) + "' })"); else return false; return true; @@ -56,7 +56,7 @@ Singleton { if (window.handle) window.handle.close(); else if (/^(0x)?[0-9a-f]+$/i.test(address)) - Hyprland.dispatch("closewindow address:" + (address.startsWith("0x") ? address : "0x" + address)); + Hyprland.dispatch("hl.dsp.window.close({ window = 'address:" + (address.startsWith("0x") ? address : "0x" + address) + "' })"); else return false; return true;