lapctl 0.1.2__tar.gz → 0.1.4__tar.gz

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.
Files changed (42) hide show
  1. {lapctl-0.1.2/src/lapctl.egg-info → lapctl-0.1.4}/PKG-INFO +1 -1
  2. {lapctl-0.1.2 → lapctl-0.1.4}/pyproject.toml +1 -1
  3. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/__init__.py +1 -1
  4. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/cli.py +149 -15
  5. {lapctl-0.1.2 → lapctl-0.1.4/src/lapctl.egg-info}/PKG-INFO +1 -1
  6. {lapctl-0.1.2 → lapctl-0.1.4}/tests/test_cli.py +51 -1
  7. {lapctl-0.1.2 → lapctl-0.1.4}/LICENSE +0 -0
  8. {lapctl-0.1.2 → lapctl-0.1.4}/README.md +0 -0
  9. {lapctl-0.1.2 → lapctl-0.1.4}/setup.cfg +0 -0
  10. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/channels/__init__.py +0 -0
  11. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/channels/telegram/__init__.py +0 -0
  12. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/channels/telegram/api.py +0 -0
  13. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/channels/telegram/auth.py +0 -0
  14. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/channels/telegram/handlers.py +0 -0
  15. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/channels/telegram/poller.py +0 -0
  16. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/channels/telegram/render.py +0 -0
  17. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/config.py +0 -0
  18. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/core/__init__.py +0 -0
  19. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/core/battery.py +0 -0
  20. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/core/commands.py +0 -0
  21. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/core/confirm.py +0 -0
  22. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/core/keyboards.py +0 -0
  23. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/core/paths.py +0 -0
  24. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/core/ratelimit.py +0 -0
  25. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/drivers/__init__.py +0 -0
  26. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/drivers/base.py +0 -0
  27. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/drivers/linux_hyprland.py +0 -0
  28. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/drivers/windows.py +0 -0
  29. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/main.py +0 -0
  30. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/registry.py +0 -0
  31. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl/results.py +0 -0
  32. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl.egg-info/SOURCES.txt +0 -0
  33. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl.egg-info/dependency_links.txt +0 -0
  34. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl.egg-info/entry_points.txt +0 -0
  35. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl.egg-info/requires.txt +0 -0
  36. {lapctl-0.1.2 → lapctl-0.1.4}/src/lapctl.egg-info/top_level.txt +0 -0
  37. {lapctl-0.1.2 → lapctl-0.1.4}/tests/test_auth_and_config.py +0 -0
  38. {lapctl-0.1.2 → lapctl-0.1.4}/tests/test_confirm.py +0 -0
  39. {lapctl-0.1.2 → lapctl-0.1.4}/tests/test_paths.py +0 -0
  40. {lapctl-0.1.2 → lapctl-0.1.4}/tests/test_registry_and_profiles.py +0 -0
  41. {lapctl-0.1.2 → lapctl-0.1.4}/tests/test_render_and_driver.py +0 -0
  42. {lapctl-0.1.2 → lapctl-0.1.4}/tests/test_windows_driver.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lapctl
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Open-source laptop remote control agent via Telegram
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.11
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "lapctl"
7
- version = "0.1.2"
7
+ version = "0.1.4"
8
8
  description = "Open-source laptop remote control agent via Telegram"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,3 +1,3 @@
1
1
  """Lapctl — remote laptop control agent."""
2
2
 
3
- __version__ = "0.1.2"
3
+ __version__ = "0.1.4"
@@ -56,65 +56,174 @@ def print_banner() -> None:
56
56
  print()
57
57
 
58
58
 
59
- DOCTOR_TOOLS: list[tuple[str, str, str]] = [
60
- ("grim", "Screenshot (/ss)", "sudo pacman -S grim | sudo apt install grim"),
59
+ DOCTOR_TOOLS: list[tuple[str, str, str, dict[str, str]]] = [
60
+ (
61
+ "grim",
62
+ "Screenshot (/ss)",
63
+ "sudo pacman -S grim | sudo apt install grim",
64
+ {"pacman": "grim", "apt": "grim", "dnf": "grim"},
65
+ ),
61
66
  (
62
67
  "ffmpeg",
63
68
  "Webcam & audio (/cam, /vid, /record)",
64
69
  "sudo pacman -S ffmpeg | sudo apt install ffmpeg",
70
+ {"pacman": "ffmpeg", "apt": "ffmpeg", "dnf": "ffmpeg"},
65
71
  ),
66
- ("wf-recorder", "Rekam layar (/screenrecord)", "sudo pacman -S wf-recorder"),
67
- ("hyprlock", "Kunci layar (/lock)", "sudo pacman -S hyprlock"),
68
- ("hyprctl", "Kontrol Hyprland & kursor", "Bagian dari paket hyprland"),
72
+ (
73
+ "wf-recorder",
74
+ "Rekam layar (/screenrecord)",
75
+ "sudo pacman -S wf-recorder",
76
+ {"pacman": "wf-recorder", "apt": "wf-recorder", "dnf": "wf-recorder"},
77
+ ),
78
+ ("hyprlock", "Kunci layar (/lock)", "sudo pacman -S hyprlock", {"pacman": "hyprlock"}),
79
+ ("hyprctl", "Kontrol Hyprland & kursor", "Bagian dari paket hyprland", {}),
69
80
  (
70
81
  "wpctl",
71
82
  "Kontrol volume & mute",
72
83
  "sudo pacman -S wireplumber | sudo apt install wireplumber",
84
+ {"pacman": "wireplumber", "apt": "wireplumber", "dnf": "wireplumber"},
73
85
  ),
74
86
  (
75
87
  "brightnessctl",
76
88
  "Kecerahan layar (/brightness)",
77
89
  "sudo pacman -S brightnessctl | sudo apt install brightnessctl",
90
+ {"pacman": "brightnessctl", "apt": "brightnessctl", "dnf": "brightnessctl"},
78
91
  ),
79
92
  (
80
93
  "playerctl",
81
94
  "Kontrol media (/play, /pause, /next)",
82
95
  "sudo pacman -S playerctl | sudo apt install playerctl",
96
+ {"pacman": "playerctl", "apt": "playerctl", "dnf": "playerctl"},
83
97
  ),
84
98
  (
85
99
  "wl-copy",
86
100
  "Clipboard tulis (/setclip)",
87
101
  "sudo pacman -S wl-clipboard | sudo apt install wl-clipboard",
102
+ {"pacman": "wl-clipboard", "apt": "wl-clipboard", "dnf": "wl-clipboard"},
88
103
  ),
89
104
  (
90
105
  "wl-paste",
91
106
  "Clipboard baca (/getclip)",
92
107
  "sudo pacman -S wl-clipboard | sudo apt install wl-clipboard",
108
+ {"pacman": "wl-clipboard", "apt": "wl-clipboard", "dnf": "wl-clipboard"},
93
109
  ),
94
- ("swww", "Wallpaper (/wallpaper)", "sudo pacman -S swww"),
110
+ ("swww", "Wallpaper (/wallpaper)", "sudo pacman -S swww", {"pacman": "swww"}),
95
111
  (
96
112
  "notify-send",
97
113
  "Notifikasi desktop (/notify)",
98
114
  "sudo pacman -S libnotify | sudo apt install libnotify-bin",
115
+ {"pacman": "libnotify", "apt": "libnotify-bin", "dnf": "libnotify"},
99
116
  ),
100
117
  (
101
118
  "xdotool",
102
119
  "Input mouse/keyboard (/mouse, /keyboard)",
103
120
  "sudo pacman -S xdotool | sudo apt install xdotool",
121
+ {"pacman": "xdotool", "apt": "xdotool", "dnf": "xdotool"},
122
+ ),
123
+ (
124
+ "mpv",
125
+ "Pemutar TTS (/say)",
126
+ "sudo pacman -S mpv | sudo apt install mpv",
127
+ {"pacman": "mpv", "apt": "mpv", "dnf": "mpv"},
104
128
  ),
105
- ("mpv", "Pemutar TTS (/say)", "sudo pacman -S mpv | sudo apt install mpv"),
106
129
  (
107
130
  "paplay",
108
131
  "Suara beep (/beep)",
109
132
  "sudo pacman -S libpulse | sudo apt install pulseaudio-utils",
133
+ {"pacman": "libpulse", "apt": "pulseaudio-utils", "dnf": "pulseaudio-utils"},
110
134
  ),
111
135
  (
112
136
  "nmcli",
113
137
  "Info WiFi (/status)",
114
138
  "sudo pacman -S networkmanager | sudo apt install network-manager",
139
+ {"pacman": "networkmanager", "apt": "network-manager", "dnf": "NetworkManager"},
115
140
  ),
116
141
  ]
117
142
 
143
+ WINDOWS_TOOLS: list[tuple[str, str, str, str]] = [
144
+ ("ffmpeg", "Rekam layar (/screenrecord)", "winget install Gyan.FFmpeg", "Gyan.FFmpeg"),
145
+ ("mpv", "Pemutar TTS (/say)", "winget install mpv.net", "mpv.net"),
146
+ ]
147
+
148
+
149
+ def _install_missing_windows_packages(ask_confirm: bool = True) -> bool:
150
+ missing = [(tool, pkg_id) for tool, _, _, pkg_id in WINDOWS_TOOLS if shutil.which(tool) is None]
151
+ if not missing:
152
+ return True
153
+ if shutil.which("winget") is None:
154
+ print("\nAlat opsional Windows belum terpasang (winget tidak ditemukan):")
155
+ for _, pkg_id in missing:
156
+ print(f" - winget install -e --id {pkg_id}")
157
+ return False
158
+
159
+ print("\nPerintah instalasi alat opsional Windows:")
160
+ for _, pkg_id in missing:
161
+ print(f" winget install -e --id {pkg_id}")
162
+
163
+ if ask_confirm:
164
+ ans = input("Pasang alat opsional yang kurang via winget sekarang? [y/N]: ").strip().lower()
165
+ if ans not in {"y", "ya", "yes"}:
166
+ return False
167
+
168
+ ok = True
169
+ for _, pkg_id in missing:
170
+ try:
171
+ res = subprocess.run(["winget", "install", "-e", "--id", pkg_id])
172
+ if res.returncode != 0:
173
+ ok = False
174
+ except Exception as e:
175
+ print(f"⚠️ Gagal memasang {pkg_id}: {e}")
176
+ ok = False
177
+ return ok
178
+
179
+
180
+ def _detect_pkg_manager() -> str | None:
181
+ for mgr, exe in (("pacman", "pacman"), ("apt", "apt-get"), ("dnf", "dnf")):
182
+ if shutil.which(exe) is not None:
183
+ return mgr
184
+ return None
185
+
186
+
187
+ def _missing_packages(pkg_mgr: str) -> list[str]:
188
+ pkgs: list[str] = []
189
+ seen: set[str] = set()
190
+ for tool, _, _, pkg_map in DOCTOR_TOOLS:
191
+ if shutil.which(tool) is None:
192
+ pkg = pkg_map.get(pkg_mgr)
193
+ if pkg and pkg not in seen:
194
+ seen.add(pkg)
195
+ pkgs.append(pkg)
196
+ return pkgs
197
+
198
+
199
+ def _install_missing_packages(ask_confirm: bool = True) -> bool:
200
+ pkg_mgr = _detect_pkg_manager()
201
+ if pkg_mgr is None:
202
+ return False
203
+ pkgs = _missing_packages(pkg_mgr)
204
+ if not pkgs:
205
+ return True
206
+
207
+ if pkg_mgr == "pacman":
208
+ cmd = ["sudo", "pacman", "-S", "--needed", *pkgs]
209
+ elif pkg_mgr == "apt":
210
+ cmd = ["sudo", "apt-get", "install", "-y", *pkgs]
211
+ else:
212
+ cmd = ["sudo", "dnf", "install", "-y", *pkgs]
213
+
214
+ print(f"\nPerintah instalasi dependensi:\n {' '.join(cmd)}")
215
+ if ask_confirm:
216
+ ans = input("Pasang paket yang kurang sekarang? [y/N]: ").strip().lower()
217
+ if ans not in {"y", "ya", "yes"}:
218
+ return False
219
+
220
+ try:
221
+ res = subprocess.run(cmd)
222
+ return res.returncode == 0
223
+ except Exception as e:
224
+ print(f"⚠️ Gagal menjalankan instalasi paket: {e}")
225
+ return False
226
+
118
227
 
119
228
  def _systemd_service_path() -> Path:
120
229
  xdg = os.environ.get("XDG_CONFIG_HOME")
@@ -316,6 +425,11 @@ def cmd_setup() -> int:
316
425
  write_toml_config(cfg_path, data)
317
426
  print(f"\n✅ Konfigurasi disimpan ke {cfg_path} (izin owner-only).")
318
427
 
428
+ if WindowsDriver.detect():
429
+ _install_missing_windows_packages(ask_confirm=True)
430
+ else:
431
+ _install_missing_packages(ask_confirm=True)
432
+
319
433
  install_svc = input("Pasang auto-start otomatis saat login? [Y/n]: ").strip().lower()
320
434
  if install_svc not in {"n", "no", "tidak"}:
321
435
  if _install_autostart():
@@ -328,7 +442,7 @@ def cmd_setup() -> int:
328
442
  return 0
329
443
 
330
444
 
331
- def cmd_doctor() -> int:
445
+ def cmd_doctor(install: bool = False) -> int:
332
446
  """Check Python, active driver, and system tool dependencies."""
333
447
  print(f"Lapctl v{__version__}")
334
448
  print(
@@ -346,16 +460,27 @@ def cmd_doctor() -> int:
346
460
  f"Konfigurasi ({cfg_path}): {'ada' if cfg_path.exists() else 'belum ada (jalankan lapctl setup)'}"
347
461
  )
348
462
  if WindowsDriver.detect():
349
- has_ffmpeg = shutil.which("ffmpeg") is not None
350
- has_mpv = shutil.which("mpv") is not None
351
463
  print("\nPemeriksaan alat opsional Windows:")
352
- print(f" - ffmpeg [{'OK' if has_ffmpeg else 'TIDAK ADA'}] Rekam layar (/screenrecord)")
353
- print(f" - mpv [{'OK' if has_mpv else 'TIDAK ADA'}] TTS (/say)")
464
+ win_missing = 0
465
+ for tool, desc, hint, _ in WINDOWS_TOOLS:
466
+ found = shutil.which(tool) is not None
467
+ status = "OK" if found else "TIDAK ADA"
468
+ print(f" - {tool:<14} [{status:<9}] {desc}")
469
+ if not found:
470
+ win_missing += 1
471
+ print(f" Saran instalasi: {hint}")
472
+ if win_missing > 0:
473
+ if install:
474
+ _install_missing_windows_packages(ask_confirm=True)
475
+ else:
476
+ print("Jalankan 'lapctl doctor --install' untuk memasang alat opsional via winget.")
477
+ else:
478
+ print("\nSemua alat opsional Windows tersedia.")
354
479
  return 0
355
480
  print("\nPemeriksaan dependensi alat:")
356
481
 
357
482
  missing = 0
358
- for tool, desc, hint in DOCTOR_TOOLS:
483
+ for tool, desc, hint, _ in DOCTOR_TOOLS:
359
484
  found = shutil.which(tool) is not None
360
485
  status = "OK" if found else "TIDAK ADA"
361
486
  print(f" - {tool:<14} [{status:<9}] {desc}")
@@ -367,6 +492,10 @@ def cmd_doctor() -> int:
367
492
  print("\nSemua alat tersedia.")
368
493
  else:
369
494
  print(f"\n{missing} alat opsional/fitur tidak ditemukan.")
495
+ if install:
496
+ _install_missing_packages(ask_confirm=True)
497
+ else:
498
+ print("Jalankan 'lapctl doctor --install' untuk memasang dependensi yang kurang.")
370
499
  return 0
371
500
 
372
501
 
@@ -522,7 +651,12 @@ def build_parser() -> argparse.ArgumentParser:
522
651
  sub.add_parser("status", help="Status service dan koneksi Telegram")
523
652
  logs_p = sub.add_parser("logs", help="Lihat log terbaru")
524
653
  logs_p.add_argument("-n", "--lines", type=int, default=30, help="Jumlah baris log")
525
- sub.add_parser("doctor", help="Cek dependensi dan kemampuan driver")
654
+ doc_p = sub.add_parser("doctor", help="Cek dependensi dan kemampuan driver")
655
+ doc_p.add_argument(
656
+ "--install",
657
+ action="store_true",
658
+ help="Tawarkan instalasi otomatis dependensi yang kurang (Linux)",
659
+ )
526
660
 
527
661
  cfg_p = sub.add_parser("config", help="Lihat atau ubah pengaturan")
528
662
  cfg_p.add_argument("--change-token", action="store_true", help="Ganti Bot Token Telegram")
@@ -558,7 +692,7 @@ def main(argv: list[str] | None = None) -> int:
558
692
  if args.command == "logs":
559
693
  return cmd_logs(lines=args.lines)
560
694
  if args.command == "doctor":
561
- return cmd_doctor()
695
+ return cmd_doctor(install=args.install)
562
696
  if args.command == "config":
563
697
  return cmd_config(args)
564
698
  if args.command == "uninstall":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lapctl
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Open-source laptop remote control agent via Telegram
5
5
  License-Expression: MIT
6
6
  Requires-Python: >=3.11
@@ -15,7 +15,7 @@ def test_cli_version(capsys) -> None:
15
15
  cli.main(["--version"])
16
16
  assert exc.value.code == 0
17
17
  out = capsys.readouterr().out
18
- assert "lapctl 0.1.2" in out
18
+ assert "lapctl 0.1.4" in out
19
19
 
20
20
 
21
21
  def test_cli_doctor_reports_missing_tools(monkeypatch, capsys) -> None:
@@ -88,3 +88,53 @@ def test_cli_config_change_token(tmp_path: Path, monkeypatch, capsys) -> None:
88
88
  assert "NEW_SECRET_TOKEN" not in out
89
89
  assert "new_lapctl_bot" in out
90
90
  assert "NEW_SECRET_TOKEN" in cfg_path.read_text(encoding="utf-8")
91
+
92
+
93
+ def test_cli_doctor_install_runs_pacman(monkeypatch) -> None:
94
+ calls: list[list[str]] = []
95
+
96
+ def fake_which(name: str) -> str | None:
97
+ if name == "pacman":
98
+ return "/usr/bin/pacman"
99
+ if name == "grim":
100
+ return "/usr/bin/grim"
101
+ return None
102
+
103
+ monkeypatch.setattr("lapctl.cli.shutil.which", fake_which)
104
+ monkeypatch.setattr("lapctl.cli.LinuxHyprlandDriver.detect", lambda: True)
105
+ monkeypatch.setattr("builtins.input", lambda _prompt: "y")
106
+ monkeypatch.setattr(
107
+ "lapctl.cli.subprocess.run",
108
+ lambda cmd, **kw: calls.append(cmd) or type("R", (), {"returncode": 0})(),
109
+ )
110
+
111
+ rc = cli.main(["doctor", "--install"])
112
+ assert rc == 0
113
+ assert len(calls) == 1
114
+ assert calls[0][:4] == ["sudo", "pacman", "-S", "--needed"]
115
+ assert "brightnessctl" in calls[0]
116
+ assert "grim" not in calls[0]
117
+
118
+
119
+ def test_cli_doctor_install_windows_runs_winget(monkeypatch) -> None:
120
+ calls: list[list[str]] = []
121
+
122
+ def fake_which(name: str) -> str | None:
123
+ if name == "winget":
124
+ return "C:\\Windows\\System32\\winget.exe"
125
+ return None
126
+
127
+ monkeypatch.setattr("lapctl.cli.shutil.which", fake_which)
128
+ monkeypatch.setattr("lapctl.cli.WindowsDriver.detect", classmethod(lambda cls: True))
129
+ monkeypatch.setattr("builtins.input", lambda _prompt: "y")
130
+ monkeypatch.setattr(
131
+ "lapctl.cli.subprocess.run",
132
+ lambda cmd, **kw: calls.append(cmd) or type("R", (), {"returncode": 0})(),
133
+ )
134
+
135
+ rc = cli.main(["doctor", "--install"])
136
+ assert rc == 0
137
+ assert calls == [
138
+ ["winget", "install", "-e", "--id", "Gyan.FFmpeg"],
139
+ ["winget", "install", "-e", "--id", "mpv.net"],
140
+ ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes