touchflow-gestures 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- touch_flow/__init__.py +3 -0
- touch_flow/backend/action_catalog.py +90 -0
- touch_flow/backend/conflict_detector.py +198 -0
- touch_flow/backend/detector.py +195 -0
- touch_flow/backend/kwin_engine.py +180 -0
- touch_flow/backend/presets.py +195 -0
- touch_flow/backend/profile_manager.py +132 -0
- touch_flow/backend/setup_manager.py +278 -0
- touch_flow/gui/action_editor.py +142 -0
- touch_flow/gui/audio_feedback.py +71 -0
- touch_flow/gui/blur_effect.py +65 -0
- touch_flow/gui/gesture_widgets.py +321 -0
- touch_flow/gui/macos_theme.py +283 -0
- touch_flow/gui/main_window.py +558 -0
- touch_flow/gui/setup_wizard.py +176 -0
- touch_flow/gui/touchpad_canvas.py +501 -0
- touch_flow/main.py +164 -0
- touchflow_gestures-0.1.0.dist-info/METADATA +32 -0
- touchflow_gestures-0.1.0.dist-info/RECORD +21 -0
- touchflow_gestures-0.1.0.dist-info/WHEEL +4 -0
- touchflow_gestures-0.1.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""Curated multi-touch gesture presets for TouchFlow."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Dict, List
|
|
6
|
+
from touch_flow.backend.kwin_engine import GestureAction, GestureRule
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_macos_preset() -> List[GestureRule]:
|
|
10
|
+
"""macOS Precision style: smooth fluid navigation and mission control."""
|
|
11
|
+
return [
|
|
12
|
+
GestureRule(
|
|
13
|
+
gesture_type="swipe",
|
|
14
|
+
fingers=3,
|
|
15
|
+
direction="up",
|
|
16
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Overview")],
|
|
17
|
+
),
|
|
18
|
+
GestureRule(
|
|
19
|
+
gesture_type="swipe",
|
|
20
|
+
fingers=3,
|
|
21
|
+
direction="down",
|
|
22
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Walk Through Windows")],
|
|
23
|
+
),
|
|
24
|
+
GestureRule(
|
|
25
|
+
gesture_type="swipe",
|
|
26
|
+
fingers=3,
|
|
27
|
+
direction="left",
|
|
28
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Quick Tile Left")],
|
|
29
|
+
),
|
|
30
|
+
GestureRule(
|
|
31
|
+
gesture_type="swipe",
|
|
32
|
+
fingers=3,
|
|
33
|
+
direction="right",
|
|
34
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Quick Tile Right")],
|
|
35
|
+
),
|
|
36
|
+
GestureRule(
|
|
37
|
+
gesture_type="pinch",
|
|
38
|
+
fingers=3,
|
|
39
|
+
direction="out",
|
|
40
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Maximize")],
|
|
41
|
+
),
|
|
42
|
+
GestureRule(
|
|
43
|
+
gesture_type="pinch",
|
|
44
|
+
fingers=3,
|
|
45
|
+
direction="in",
|
|
46
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Restore")],
|
|
47
|
+
),
|
|
48
|
+
GestureRule(
|
|
49
|
+
gesture_type="swipe",
|
|
50
|
+
fingers=4,
|
|
51
|
+
direction="left",
|
|
52
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Switch One Desktop to the Right")],
|
|
53
|
+
),
|
|
54
|
+
GestureRule(
|
|
55
|
+
gesture_type="swipe",
|
|
56
|
+
fingers=4,
|
|
57
|
+
direction="right",
|
|
58
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Switch One Desktop to the Left")],
|
|
59
|
+
),
|
|
60
|
+
GestureRule(
|
|
61
|
+
gesture_type="swipe",
|
|
62
|
+
fingers=4,
|
|
63
|
+
direction="up",
|
|
64
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Fullscreen")],
|
|
65
|
+
),
|
|
66
|
+
GestureRule(
|
|
67
|
+
gesture_type="swipe",
|
|
68
|
+
fingers=4,
|
|
69
|
+
direction="down",
|
|
70
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Show Desktop")],
|
|
71
|
+
),
|
|
72
|
+
GestureRule(
|
|
73
|
+
gesture_type="hold",
|
|
74
|
+
fingers=4,
|
|
75
|
+
direction=None,
|
|
76
|
+
instant=False,
|
|
77
|
+
actions=[GestureAction(kind="plasma_shortcut", target="ksmserver,Lock Session")],
|
|
78
|
+
),
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def get_windows11_preset() -> List[GestureRule]:
|
|
83
|
+
"""Windows 11 Precision style: Task View, show desktop, and desktop switching."""
|
|
84
|
+
return [
|
|
85
|
+
GestureRule(
|
|
86
|
+
gesture_type="swipe",
|
|
87
|
+
fingers=3,
|
|
88
|
+
direction="up",
|
|
89
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Overview")],
|
|
90
|
+
),
|
|
91
|
+
GestureRule(
|
|
92
|
+
gesture_type="swipe",
|
|
93
|
+
fingers=3,
|
|
94
|
+
direction="down",
|
|
95
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Show Desktop")],
|
|
96
|
+
),
|
|
97
|
+
GestureRule(
|
|
98
|
+
gesture_type="swipe",
|
|
99
|
+
fingers=3,
|
|
100
|
+
direction="left",
|
|
101
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Walk Through Windows")],
|
|
102
|
+
),
|
|
103
|
+
GestureRule(
|
|
104
|
+
gesture_type="swipe",
|
|
105
|
+
fingers=3,
|
|
106
|
+
direction="right",
|
|
107
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Walk Through Windows (Reverse)")],
|
|
108
|
+
),
|
|
109
|
+
GestureRule(
|
|
110
|
+
gesture_type="swipe",
|
|
111
|
+
fingers=4,
|
|
112
|
+
direction="left",
|
|
113
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Switch One Desktop to the Right")],
|
|
114
|
+
),
|
|
115
|
+
GestureRule(
|
|
116
|
+
gesture_type="swipe",
|
|
117
|
+
fingers=4,
|
|
118
|
+
direction="right",
|
|
119
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Switch One Desktop to the Left")],
|
|
120
|
+
),
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def get_tiling_preset() -> List[GestureRule]:
|
|
125
|
+
"""Power-User Tiling: Fast tiling, maximizing, and fullscreens."""
|
|
126
|
+
return [
|
|
127
|
+
GestureRule(
|
|
128
|
+
gesture_type="swipe",
|
|
129
|
+
fingers=3,
|
|
130
|
+
direction="left",
|
|
131
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Quick Tile Left")],
|
|
132
|
+
),
|
|
133
|
+
GestureRule(
|
|
134
|
+
gesture_type="swipe",
|
|
135
|
+
fingers=3,
|
|
136
|
+
direction="right",
|
|
137
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Quick Tile Right")],
|
|
138
|
+
),
|
|
139
|
+
GestureRule(
|
|
140
|
+
gesture_type="swipe",
|
|
141
|
+
fingers=3,
|
|
142
|
+
direction="up",
|
|
143
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Maximize")],
|
|
144
|
+
),
|
|
145
|
+
GestureRule(
|
|
146
|
+
gesture_type="swipe",
|
|
147
|
+
fingers=3,
|
|
148
|
+
direction="down",
|
|
149
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Minimize")],
|
|
150
|
+
),
|
|
151
|
+
GestureRule(
|
|
152
|
+
gesture_type="swipe",
|
|
153
|
+
fingers=4,
|
|
154
|
+
direction="left",
|
|
155
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Switch One Desktop to the Right")],
|
|
156
|
+
),
|
|
157
|
+
GestureRule(
|
|
158
|
+
gesture_type="swipe",
|
|
159
|
+
fingers=4,
|
|
160
|
+
direction="right",
|
|
161
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Switch One Desktop to the Left")],
|
|
162
|
+
),
|
|
163
|
+
GestureRule(
|
|
164
|
+
gesture_type="swipe",
|
|
165
|
+
fingers=4,
|
|
166
|
+
direction="up",
|
|
167
|
+
actions=[GestureAction(kind="plasma_shortcut", target="kwin,Window Fullscreen")],
|
|
168
|
+
),
|
|
169
|
+
GestureRule(
|
|
170
|
+
gesture_type="hold",
|
|
171
|
+
fingers=4,
|
|
172
|
+
direction=None,
|
|
173
|
+
instant=False,
|
|
174
|
+
actions=[GestureAction(kind="plasma_shortcut", target="ksmserver,Lock Session")],
|
|
175
|
+
),
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
BUILTIN_PRESETS: Dict[str, dict] = {
|
|
180
|
+
"macos": {
|
|
181
|
+
"name": "macOS Precision",
|
|
182
|
+
"description": "Fluid desktop navigation, overview, quick tile, and lock session.",
|
|
183
|
+
"generator": get_macos_preset,
|
|
184
|
+
},
|
|
185
|
+
"windows11": {
|
|
186
|
+
"name": "Windows 11 Precision",
|
|
187
|
+
"description": "Task View overview, desktop toggling, and fast app switcher.",
|
|
188
|
+
"generator": get_windows11_preset,
|
|
189
|
+
},
|
|
190
|
+
"tiling": {
|
|
191
|
+
"name": "Power Tiling",
|
|
192
|
+
"description": "Instant window snapping, maximizing, and workspace hopping.",
|
|
193
|
+
"generator": get_tiling_preset,
|
|
194
|
+
},
|
|
195
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Profile manager for saving, loading, and switching gesture configurations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from dataclasses import asdict, dataclass, field
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Dict, List, Optional
|
|
9
|
+
|
|
10
|
+
from touch_flow.backend.kwin_engine import GestureAction, GestureRule, KWinInputActionsEngine
|
|
11
|
+
from touch_flow.backend.presets import BUILTIN_PRESETS
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class GestureProfile:
|
|
16
|
+
"""Represents a named gesture profile."""
|
|
17
|
+
|
|
18
|
+
name: str
|
|
19
|
+
description: str = ""
|
|
20
|
+
rules: List[GestureRule] = field(default_factory=list)
|
|
21
|
+
is_preset: bool = False
|
|
22
|
+
|
|
23
|
+
def to_dict(self) -> dict:
|
|
24
|
+
return {
|
|
25
|
+
"name": self.name,
|
|
26
|
+
"description": self.description,
|
|
27
|
+
"is_preset": self.is_preset,
|
|
28
|
+
"rules": [r.to_dict() for r in self.rules],
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def from_dict(cls, data: dict) -> "GestureProfile":
|
|
33
|
+
rules = [GestureRule.from_dict(r) for r in data.get("rules", [])]
|
|
34
|
+
return cls(
|
|
35
|
+
name=data.get("name", "Unnamed Profile"),
|
|
36
|
+
description=data.get("description", ""),
|
|
37
|
+
rules=rules,
|
|
38
|
+
is_preset=data.get("is_preset", False),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ProfileManager:
|
|
43
|
+
"""Manages built-in and user-created gesture profiles."""
|
|
44
|
+
|
|
45
|
+
DEFAULT_PROFILES_DIR = Path.home() / ".config" / "touchflow" / "profiles"
|
|
46
|
+
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
profiles_dir: Optional[Path] = None,
|
|
50
|
+
kwin_engine: Optional[KWinInputActionsEngine] = None,
|
|
51
|
+
):
|
|
52
|
+
self.profiles_dir = profiles_dir or self.DEFAULT_PROFILES_DIR
|
|
53
|
+
self.kwin_engine = kwin_engine or KWinInputActionsEngine()
|
|
54
|
+
|
|
55
|
+
def list_profiles(self) -> List[GestureProfile]:
|
|
56
|
+
"""List all available presets and saved user profiles."""
|
|
57
|
+
profiles: List[GestureProfile] = []
|
|
58
|
+
|
|
59
|
+
# 1. Built-in presets
|
|
60
|
+
for key, preset in BUILTIN_PRESETS.items():
|
|
61
|
+
profiles.append(
|
|
62
|
+
GestureProfile(
|
|
63
|
+
name=preset["name"],
|
|
64
|
+
description=preset["description"],
|
|
65
|
+
rules=preset["generator"](),
|
|
66
|
+
is_preset=True,
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# 2. Saved user profiles
|
|
71
|
+
if self.profiles_dir.exists():
|
|
72
|
+
for p_file in sorted(self.profiles_dir.glob("*.json")):
|
|
73
|
+
try:
|
|
74
|
+
data = json.loads(p_file.read_text(encoding="utf-8"))
|
|
75
|
+
profiles.append(GestureProfile.from_dict(data))
|
|
76
|
+
except Exception:
|
|
77
|
+
pass
|
|
78
|
+
|
|
79
|
+
return profiles
|
|
80
|
+
|
|
81
|
+
def save_profile(self, profile: GestureProfile) -> bool:
|
|
82
|
+
"""Save a custom user profile to disk."""
|
|
83
|
+
try:
|
|
84
|
+
self.profiles_dir.mkdir(parents=True, exist_ok=True)
|
|
85
|
+
safe_filename = "".join(c for c in profile.name if c.isalnum() or c in ("-", "_")).lower()
|
|
86
|
+
file_path = self.profiles_dir / f"{safe_filename}.json"
|
|
87
|
+
file_path.write_text(json.dumps(profile.to_dict(), indent=2), encoding="utf-8")
|
|
88
|
+
return True
|
|
89
|
+
except Exception:
|
|
90
|
+
return False
|
|
91
|
+
|
|
92
|
+
def get_current_active_profile(self) -> GestureProfile:
|
|
93
|
+
"""Load currently active rules from the system."""
|
|
94
|
+
rules = self.kwin_engine.load_rules()
|
|
95
|
+
return GestureProfile(
|
|
96
|
+
name="Current Active",
|
|
97
|
+
description="Currently active gesture bindings in system.",
|
|
98
|
+
rules=rules,
|
|
99
|
+
is_preset=False,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
def apply_profile(self, profile: GestureProfile, reload_compositor: bool = True) -> bool:
|
|
103
|
+
"""Write profile rules to the system and reload compositor."""
|
|
104
|
+
saved = self.kwin_engine.save_rules(profile.rules, backup=True)
|
|
105
|
+
if saved and reload_compositor:
|
|
106
|
+
self.kwin_engine.reload_kwin()
|
|
107
|
+
return saved
|
|
108
|
+
|
|
109
|
+
def export_profile(self, profile: GestureProfile, dest_path: Path) -> bool:
|
|
110
|
+
"""Export a GestureProfile to a standalone JSON file."""
|
|
111
|
+
try:
|
|
112
|
+
dest_path.parent.mkdir(parents=True, exist_ok=True)
|
|
113
|
+
payload = profile.to_dict()
|
|
114
|
+
payload["is_preset"] = False
|
|
115
|
+
dest_path.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
|
116
|
+
return True
|
|
117
|
+
except Exception:
|
|
118
|
+
return False
|
|
119
|
+
|
|
120
|
+
def import_profile(self, src_path: Path) -> Optional[GestureProfile]:
|
|
121
|
+
"""Import and validate a GestureProfile from a JSON file."""
|
|
122
|
+
if not src_path.exists():
|
|
123
|
+
return None
|
|
124
|
+
try:
|
|
125
|
+
data = json.loads(src_path.read_text(encoding="utf-8"))
|
|
126
|
+
if not isinstance(data, dict) or "rules" not in data or not isinstance(data["rules"], list):
|
|
127
|
+
return None
|
|
128
|
+
profile = GestureProfile.from_dict(data)
|
|
129
|
+
profile.is_preset = False
|
|
130
|
+
return profile
|
|
131
|
+
except Exception:
|
|
132
|
+
return None
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"""System dependency diagnostics, XDG desktop integration, and first-run setup."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib.util
|
|
6
|
+
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Callable, Dict, List, Optional
|
|
12
|
+
|
|
13
|
+
from touch_flow.backend.conflict_detector import ConflictDetector
|
|
14
|
+
from touch_flow.backend.detector import detect_desktop_environment, detect_touchpads
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
PACKAGE_MANAGER_HINTS: Dict[str, Dict[str, str]] = {
|
|
18
|
+
"pacman": {
|
|
19
|
+
"name": "pacman (Arch / EndeavourOS)",
|
|
20
|
+
"system_deps": "sudo pacman -S --needed python python-pyside6 python-yaml qt6-tools",
|
|
21
|
+
"inputactions": "yay -S inputactions-kwin # or paru -S inputactions-kwin",
|
|
22
|
+
},
|
|
23
|
+
"apt": {
|
|
24
|
+
"name": "apt (Debian / Ubuntu)",
|
|
25
|
+
"system_deps": "sudo apt update && sudo apt install -y python3 python3-pyside6 python3-yaml qt6-tools-dev-tools",
|
|
26
|
+
"inputactions": "Build or install inputactions-kwin from KDE/GitHub releases.",
|
|
27
|
+
},
|
|
28
|
+
"dnf": {
|
|
29
|
+
"name": "dnf (Fedora)",
|
|
30
|
+
"system_deps": "sudo dnf install -y python3 python3-pyside6 python3-pyyaml qt6-qttools",
|
|
31
|
+
"inputactions": "Install inputactions-kwin from COPR or build from source.",
|
|
32
|
+
},
|
|
33
|
+
"unknown": {
|
|
34
|
+
"name": "Unknown package manager",
|
|
35
|
+
"system_deps": "pip install PySide6 pyyaml (and install qt6-tools / qdbus6 via your distro)",
|
|
36
|
+
"inputactions": "Install inputactions-kwin for KDE Plasma Wayland.",
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def detect_package_manager(which_fn: Callable[[str], Optional[str]] = shutil.which) -> str:
|
|
42
|
+
"""Detect the host Linux distribution package manager."""
|
|
43
|
+
if which_fn("pacman"):
|
|
44
|
+
return "pacman"
|
|
45
|
+
if which_fn("apt-get") or which_fn("apt"):
|
|
46
|
+
return "apt"
|
|
47
|
+
if which_fn("dnf"):
|
|
48
|
+
return "dnf"
|
|
49
|
+
return "unknown"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@dataclass
|
|
53
|
+
class DependencyCheck:
|
|
54
|
+
"""Single environment or dependency diagnostic result."""
|
|
55
|
+
|
|
56
|
+
id: str
|
|
57
|
+
name: str
|
|
58
|
+
ok: bool
|
|
59
|
+
detail: str
|
|
60
|
+
fix_hint: str = ""
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass
|
|
64
|
+
class DoctorReport:
|
|
65
|
+
"""Aggregated system health and dependency diagnostic report."""
|
|
66
|
+
|
|
67
|
+
package_manager: str
|
|
68
|
+
checks: List[DependencyCheck] = field(default_factory=list)
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def all_ok(self) -> bool:
|
|
72
|
+
return all(c.ok for c in self.checks)
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def missing_count(self) -> int:
|
|
76
|
+
return sum(1 for c in self.checks if not c.ok)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class SystemSetupManager:
|
|
80
|
+
"""Manages dependency checks, XDG desktop/icon/systemd files, and first-run state."""
|
|
81
|
+
|
|
82
|
+
def __init__(
|
|
83
|
+
self,
|
|
84
|
+
data_home: Optional[Path] = None,
|
|
85
|
+
config_home: Optional[Path] = None,
|
|
86
|
+
kwin_config_path: Optional[Path] = None,
|
|
87
|
+
):
|
|
88
|
+
self.data_home = data_home or (Path.home() / ".local" / "share")
|
|
89
|
+
self.config_home = config_home or (Path.home() / ".config")
|
|
90
|
+
self.kwin_config_path = kwin_config_path or (self.config_home / "inputactions" / "config.yaml")
|
|
91
|
+
|
|
92
|
+
self.applications_dir = self.data_home / "applications"
|
|
93
|
+
self.icons_dir = self.data_home / "icons" / "hicolor" / "scalable" / "apps"
|
|
94
|
+
self.systemd_user_dir = self.config_home / "systemd" / "user"
|
|
95
|
+
|
|
96
|
+
def is_first_run(self) -> bool:
|
|
97
|
+
"""Return True if TouchFlow has not yet configured gesture rules on this system."""
|
|
98
|
+
return not self.kwin_config_path.exists()
|
|
99
|
+
|
|
100
|
+
def run_doctor(
|
|
101
|
+
self,
|
|
102
|
+
which_fn: Callable[[str], Optional[str]] = shutil.which,
|
|
103
|
+
) -> DoctorReport:
|
|
104
|
+
"""Run full dependency, hardware, compositor, and conflict diagnostics."""
|
|
105
|
+
pkg_mgr = detect_package_manager(which_fn=which_fn)
|
|
106
|
+
hints = PACKAGE_MANAGER_HINTS.get(pkg_mgr, PACKAGE_MANAGER_HINTS["unknown"])
|
|
107
|
+
checks: List[DependencyCheck] = []
|
|
108
|
+
|
|
109
|
+
# 1. Python PySide6
|
|
110
|
+
has_pyside = importlib.util.find_spec("PySide6") is not None
|
|
111
|
+
checks.append(
|
|
112
|
+
DependencyCheck(
|
|
113
|
+
id="pyside6",
|
|
114
|
+
name="PySide6 (Qt6 GUI)",
|
|
115
|
+
ok=has_pyside,
|
|
116
|
+
detail="Installed" if has_pyside else "Missing PySide6 Python package",
|
|
117
|
+
fix_hint="" if has_pyside else hints["system_deps"],
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# 2. PyYAML
|
|
122
|
+
has_yaml = importlib.util.find_spec("yaml") is not None
|
|
123
|
+
checks.append(
|
|
124
|
+
DependencyCheck(
|
|
125
|
+
id="pyyaml",
|
|
126
|
+
name="PyYAML",
|
|
127
|
+
ok=has_yaml,
|
|
128
|
+
detail="Installed" if has_yaml else "Missing pyyaml Python package",
|
|
129
|
+
fix_hint="" if has_yaml else hints["system_deps"],
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# 3. qdbus6 / qdbus
|
|
134
|
+
qdbus_bin = which_fn("qdbus6") or which_fn("qdbus")
|
|
135
|
+
checks.append(
|
|
136
|
+
DependencyCheck(
|
|
137
|
+
id="qdbus",
|
|
138
|
+
name="KWin D-Bus CLI (qdbus6/qdbus)",
|
|
139
|
+
ok=bool(qdbus_bin),
|
|
140
|
+
detail=f"Found at {qdbus_bin}" if qdbus_bin else "qdbus6/qdbus not found in PATH",
|
|
141
|
+
fix_hint="" if qdbus_bin else hints["system_deps"],
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# 4. Touchpad hardware
|
|
146
|
+
touchpads = detect_touchpads()
|
|
147
|
+
checks.append(
|
|
148
|
+
DependencyCheck(
|
|
149
|
+
id="touchpad",
|
|
150
|
+
name="Touchpad Hardware",
|
|
151
|
+
ok=len(touchpads) > 0,
|
|
152
|
+
detail=touchpads[0].name if touchpads else "No touchpad detected in /proc/bus/input/devices",
|
|
153
|
+
fix_hint="" if touchpads else "Ensure a touchpad is connected and readable.",
|
|
154
|
+
)
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# 5. Desktop environment & InputActions
|
|
158
|
+
env = detect_desktop_environment()
|
|
159
|
+
de_ok = env.desktop != "KDE" or env.has_kwin_dbus or env.has_inputactions_kwin
|
|
160
|
+
checks.append(
|
|
161
|
+
DependencyCheck(
|
|
162
|
+
id="desktop_env",
|
|
163
|
+
name="Desktop & Compositor",
|
|
164
|
+
ok=de_ok,
|
|
165
|
+
detail=env.details,
|
|
166
|
+
fix_hint="" if de_ok else hints["inputactions"],
|
|
167
|
+
)
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
# 6. Conflicting daemons
|
|
171
|
+
conflicts = [c for c in ConflictDetector().scan_all() if c.has_conflict]
|
|
172
|
+
checks.append(
|
|
173
|
+
DependencyCheck(
|
|
174
|
+
id="conflicts",
|
|
175
|
+
name="Conflicting Gesture Daemons",
|
|
176
|
+
ok=len(conflicts) == 0,
|
|
177
|
+
detail=(
|
|
178
|
+
"None active"
|
|
179
|
+
if not conflicts
|
|
180
|
+
else f"Active conflicts: {', '.join(c.name for c in conflicts)}"
|
|
181
|
+
),
|
|
182
|
+
fix_hint="" if not conflicts else "Run 'touch-flow --neutralize-conflicts' or use the Health Wizard.",
|
|
183
|
+
)
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
return DoctorReport(package_manager=pkg_mgr, checks=checks)
|
|
187
|
+
|
|
188
|
+
@staticmethod
|
|
189
|
+
def generate_desktop_entry(exec_cmd: str = "touch-flow", icon_name: str = "touch-flow") -> str:
|
|
190
|
+
"""Generate XDG .desktop application entry content."""
|
|
191
|
+
return (
|
|
192
|
+
"[Desktop Entry]\n"
|
|
193
|
+
"Type=Application\n"
|
|
194
|
+
"Name=TouchFlow\n"
|
|
195
|
+
"GenericName=Multi-Touch Gesture Manager\n"
|
|
196
|
+
"Comment=Universal Linux multi-touch gesture manager\n"
|
|
197
|
+
f"Exec={exec_cmd}\n"
|
|
198
|
+
f"Icon={icon_name}\n"
|
|
199
|
+
"Terminal=false\n"
|
|
200
|
+
"Categories=Settings;System;Utility;Qt;\n"
|
|
201
|
+
"Keywords=touchpad;gestures;libinput;wayland;kde;\n"
|
|
202
|
+
"StartupNotify=true\n"
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
@staticmethod
|
|
206
|
+
def generate_svg_icon() -> str:
|
|
207
|
+
"""Generate a clean scalable SVG application icon for TouchFlow."""
|
|
208
|
+
return (
|
|
209
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">\n'
|
|
210
|
+
' <rect x="8" y="16" width="112" height="96" rx="18" fill="#18181b" stroke="#38bdf8" stroke-width="4"/>\n'
|
|
211
|
+
' <line x1="64" y1="92" x2="64" y2="112" stroke="#3f3f46" stroke-width="3"/>\n'
|
|
212
|
+
' <circle cx="40" cy="58" r="10" fill="#38bdf8" fill-opacity="0.9"/>\n'
|
|
213
|
+
' <circle cx="64" cy="52" r="10" fill="#38bdf8"/>\n'
|
|
214
|
+
' <circle cx="88" cy="58" r="10" fill="#38bdf8" fill-opacity="0.9"/>\n'
|
|
215
|
+
"</svg>\n"
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
@staticmethod
|
|
219
|
+
def generate_systemd_service(exec_cmd: str = "touch-flow") -> str:
|
|
220
|
+
"""Generate a rootless systemd user service to keep conflicts neutralized on login."""
|
|
221
|
+
return (
|
|
222
|
+
"[Unit]\n"
|
|
223
|
+
"Description=TouchFlow Gesture Environment Guard\n"
|
|
224
|
+
"After=graphical-session.target\n"
|
|
225
|
+
"\n"
|
|
226
|
+
"[Service]\n"
|
|
227
|
+
"Type=oneshot\n"
|
|
228
|
+
f"ExecStart={exec_cmd} --neutralize-conflicts\n"
|
|
229
|
+
"RemainAfterExit=yes\n"
|
|
230
|
+
"\n"
|
|
231
|
+
"[Install]\n"
|
|
232
|
+
"WantedBy=graphical-session.target\n"
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
def install_desktop_integration(
|
|
236
|
+
self,
|
|
237
|
+
exec_cmd: Optional[str] = None,
|
|
238
|
+
enable_systemd: bool = True,
|
|
239
|
+
) -> Dict[str, Path]:
|
|
240
|
+
"""Install .desktop entry, SVG icon, and systemd user unit."""
|
|
241
|
+
resolved_exec = exec_cmd or shutil.which("touch-flow") or f"{sys.executable} -m touch_flow.main"
|
|
242
|
+
|
|
243
|
+
self.applications_dir.mkdir(parents=True, exist_ok=True)
|
|
244
|
+
self.icons_dir.mkdir(parents=True, exist_ok=True)
|
|
245
|
+
self.systemd_user_dir.mkdir(parents=True, exist_ok=True)
|
|
246
|
+
|
|
247
|
+
desktop_path = self.applications_dir / "touch-flow.desktop"
|
|
248
|
+
icon_path = self.icons_dir / "touch-flow.svg"
|
|
249
|
+
service_path = self.systemd_user_dir / "touch-flow.service"
|
|
250
|
+
|
|
251
|
+
desktop_path.write_text(self.generate_desktop_entry(exec_cmd=resolved_exec), encoding="utf-8")
|
|
252
|
+
icon_path.write_text(self.generate_svg_icon(), encoding="utf-8")
|
|
253
|
+
service_path.write_text(self.generate_systemd_service(exec_cmd=resolved_exec), encoding="utf-8")
|
|
254
|
+
|
|
255
|
+
if enable_systemd and shutil.which("systemctl"):
|
|
256
|
+
try:
|
|
257
|
+
subprocess.run(
|
|
258
|
+
["systemctl", "--user", "daemon-reload"],
|
|
259
|
+
stdout=subprocess.PIPE,
|
|
260
|
+
stderr=subprocess.PIPE,
|
|
261
|
+
check=False,
|
|
262
|
+
timeout=3.0,
|
|
263
|
+
)
|
|
264
|
+
subprocess.run(
|
|
265
|
+
["systemctl", "--user", "enable", "touch-flow.service"],
|
|
266
|
+
stdout=subprocess.PIPE,
|
|
267
|
+
stderr=subprocess.PIPE,
|
|
268
|
+
check=False,
|
|
269
|
+
timeout=3.0,
|
|
270
|
+
)
|
|
271
|
+
except Exception:
|
|
272
|
+
pass
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
"desktop": desktop_path,
|
|
276
|
+
"icon": icon_path,
|
|
277
|
+
"service": service_path,
|
|
278
|
+
}
|