Skip to content

Commit b9a442d

Browse files
committed
fix: lua detection systeminfo -> status
Closes #130
1 parent 1953345 commit b9a442d

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

src/caelestia/utils/hypr.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
_lua_config_cache: bool | None = None
1111

12+
1213
def message(msg: str, is_json: bool = True) -> str | dict[str, Any]:
1314
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
1415
sock.connect(socket_path)
@@ -32,24 +33,25 @@ def is_lua_config() -> bool:
3233
if _lua_config_cache is not None:
3334
return _lua_config_cache
3435
try:
35-
result = message("systeminfo", is_json=False)
36-
for line in result.splitlines():
37-
if "configProvider:" in line:
38-
_lua_config_cache = "lua" in line.lower()
39-
return _lua_config_cache
40-
_lua_config_cache = False
41-
return False
36+
result = message("status")
37+
if isinstance(result, dict):
38+
_lua_config_cache = bool(result["configProvider"] == "lua")
39+
else:
40+
_lua_config_cache = False
41+
return _lua_config_cache
4242
except Exception:
4343
_lua_config_cache = False
4444
return False
4545

4646

4747
DISPATCHER_MAP_LUA = {
48-
"togglespecialworkspace": lambda *a: f'hl.dsp.workspace.toggle_special("{a[0]}")' if a else 'hl.dsp.workspace.toggle_special()',
48+
"togglespecialworkspace": lambda *a: (
49+
f'hl.dsp.workspace.toggle_special("{a[0]}")' if a else "hl.dsp.workspace.toggle_special()"
50+
),
4951
"movetoworkspacesilent": lambda *a: (
50-
f'hl.dsp.window.move({{window = "address:{a[0].split(",")[1].replace("address:", "")}", workspace = "{a[0].split(",")[0]}", follow = false}})'
51-
),
52-
"exec": lambda *a: 'hl.dsp.exec_cmd("' + ' '.join(a).replace('\\', '\\\\').replace('"', '\\"') + '")',
52+
f'hl.dsp.window.move({{window = "address:{a[0].split(",")[1].replace("address:", "")}", workspace = "{a[0].split(",")[0]}", follow = false}})'
53+
),
54+
"exec": lambda *a: 'hl.dsp.exec_cmd("' + " ".join(a).replace("\\", "\\\\").replace('"', '\\"') + '")',
5355
}
5456

5557

0 commit comments

Comments
 (0)