fix: bypass kglobalaccel in workspace_service.py using direct KWin VirtualDesktopManager DBus calls
This commit is contained in:
parent
f495a4f8e2
commit
8efe6d5198
@ -65,15 +65,32 @@ def get_status():
|
|||||||
}
|
}
|
||||||
|
|
||||||
def switch_to(index):
|
def switch_to(index):
|
||||||
|
try:
|
||||||
|
idx_target = int(index)
|
||||||
|
desktops_raw = subprocess.check_output(
|
||||||
|
["qdbus6", "--literal", "org.kde.KWin", "/VirtualDesktopManager", "org.kde.KWin.VirtualDesktopManager.desktops"],
|
||||||
|
text=True, stderr=subprocess.DEVNULL
|
||||||
|
)
|
||||||
|
matches = re.findall(r'\(uss\)\s*(\d+),\s*"([^"]+)"(?:,\s*"([^"]*)")?', desktops_raw)
|
||||||
|
if matches and 1 <= idx_target <= len(matches):
|
||||||
|
target_uuid = matches[idx_target - 1][1]
|
||||||
|
res = subprocess.run(
|
||||||
|
["qdbus6", "org.kde.KWin", "/VirtualDesktopManager", "org.kde.KWin.VirtualDesktopManager.setCurrent", target_uuid],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
||||||
|
)
|
||||||
|
if res.returncode == 0:
|
||||||
|
return
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shortcut_name = f"Switch to Desktop {index}"
|
shortcut_name = f"Switch to Desktop {index}"
|
||||||
res = subprocess.run(
|
res = subprocess.run(
|
||||||
["qdbus6", "org.kde.kglobalaccel", "/component/kwin", "org.kde.kglobalaccel.Component.invokeShortcut", shortcut_name],
|
["qdbus6", "org.kde.kglobalaccel", "/component/kwin", "org.kde.kglobalaccel.Component.invokeShortcut", shortcut_name],
|
||||||
capture_output=True, text=True
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
||||||
)
|
)
|
||||||
if res.returncode != 0:
|
if res.returncode != 0:
|
||||||
# Hyprland fallback
|
subprocess.run(["hyprctl", "dispatch", "workspace", str(index)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
subprocess.run(["hyprctl", "dispatch", "workspace", str(index)], capture_output=True)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user