lapctl 0.1.2__tar.gz → 0.1.3__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.
- {lapctl-0.1.2/src/lapctl.egg-info → lapctl-0.1.3}/PKG-INFO +1 -1
- {lapctl-0.1.2 → lapctl-0.1.3}/pyproject.toml +1 -1
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/__init__.py +1 -1
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/cli.py +96 -11
- {lapctl-0.1.2 → lapctl-0.1.3/src/lapctl.egg-info}/PKG-INFO +1 -1
- {lapctl-0.1.2 → lapctl-0.1.3}/tests/test_cli.py +27 -1
- {lapctl-0.1.2 → lapctl-0.1.3}/LICENSE +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/README.md +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/setup.cfg +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/channels/__init__.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/channels/telegram/__init__.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/channels/telegram/api.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/channels/telegram/auth.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/channels/telegram/handlers.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/channels/telegram/poller.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/channels/telegram/render.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/config.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/core/__init__.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/core/battery.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/core/commands.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/core/confirm.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/core/keyboards.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/core/paths.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/core/ratelimit.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/drivers/__init__.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/drivers/base.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/drivers/linux_hyprland.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/drivers/windows.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/main.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/registry.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl/results.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl.egg-info/SOURCES.txt +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl.egg-info/dependency_links.txt +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl.egg-info/entry_points.txt +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl.egg-info/requires.txt +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/src/lapctl.egg-info/top_level.txt +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/tests/test_auth_and_config.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/tests/test_confirm.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/tests/test_paths.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/tests/test_registry_and_profiles.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/tests/test_render_and_driver.py +0 -0
- {lapctl-0.1.2 → lapctl-0.1.3}/tests/test_windows_driver.py +0 -0
|
@@ -56,66 +56,139 @@ def print_banner() -> None:
|
|
|
56
56
|
print()
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
DOCTOR_TOOLS: list[tuple[str, str, str]] = [
|
|
60
|
-
(
|
|
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"},
|
|
71
|
+
),
|
|
72
|
+
(
|
|
73
|
+
"wf-recorder",
|
|
74
|
+
"Rekam layar (/screenrecord)",
|
|
75
|
+
"sudo pacman -S wf-recorder",
|
|
76
|
+
{"pacman": "wf-recorder", "apt": "wf-recorder", "dnf": "wf-recorder"},
|
|
65
77
|
),
|
|
66
|
-
("
|
|
67
|
-
("
|
|
68
|
-
("hyprctl", "Kontrol Hyprland & kursor", "Bagian dari paket hyprland"),
|
|
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
|
|
|
118
143
|
|
|
144
|
+
def _detect_pkg_manager() -> str | None:
|
|
145
|
+
for mgr, exe in (("pacman", "pacman"), ("apt", "apt-get"), ("dnf", "dnf")):
|
|
146
|
+
if shutil.which(exe) is not None:
|
|
147
|
+
return mgr
|
|
148
|
+
return None
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def _missing_packages(pkg_mgr: str) -> list[str]:
|
|
152
|
+
pkgs: list[str] = []
|
|
153
|
+
seen: set[str] = set()
|
|
154
|
+
for tool, _, _, pkg_map in DOCTOR_TOOLS:
|
|
155
|
+
if shutil.which(tool) is None:
|
|
156
|
+
pkg = pkg_map.get(pkg_mgr)
|
|
157
|
+
if pkg and pkg not in seen:
|
|
158
|
+
seen.add(pkg)
|
|
159
|
+
pkgs.append(pkg)
|
|
160
|
+
return pkgs
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _install_missing_packages(ask_confirm: bool = True) -> bool:
|
|
164
|
+
pkg_mgr = _detect_pkg_manager()
|
|
165
|
+
if pkg_mgr is None:
|
|
166
|
+
return False
|
|
167
|
+
pkgs = _missing_packages(pkg_mgr)
|
|
168
|
+
if not pkgs:
|
|
169
|
+
return True
|
|
170
|
+
|
|
171
|
+
if pkg_mgr == "pacman":
|
|
172
|
+
cmd = ["sudo", "pacman", "-S", "--needed", *pkgs]
|
|
173
|
+
elif pkg_mgr == "apt":
|
|
174
|
+
cmd = ["sudo", "apt-get", "install", "-y", *pkgs]
|
|
175
|
+
else:
|
|
176
|
+
cmd = ["sudo", "dnf", "install", "-y", *pkgs]
|
|
177
|
+
|
|
178
|
+
print(f"\nPerintah instalasi dependensi:\n {' '.join(cmd)}")
|
|
179
|
+
if ask_confirm:
|
|
180
|
+
ans = input("Pasang paket yang kurang sekarang? [y/N]: ").strip().lower()
|
|
181
|
+
if ans not in {"y", "ya", "yes"}:
|
|
182
|
+
return False
|
|
183
|
+
|
|
184
|
+
try:
|
|
185
|
+
res = subprocess.run(cmd)
|
|
186
|
+
return res.returncode == 0
|
|
187
|
+
except Exception as e:
|
|
188
|
+
print(f"⚠️ Gagal menjalankan instalasi paket: {e}")
|
|
189
|
+
return False
|
|
190
|
+
|
|
191
|
+
|
|
119
192
|
def _systemd_service_path() -> Path:
|
|
120
193
|
xdg = os.environ.get("XDG_CONFIG_HOME")
|
|
121
194
|
base = Path(xdg) if xdg else Path.home() / ".config"
|
|
@@ -316,6 +389,9 @@ def cmd_setup() -> int:
|
|
|
316
389
|
write_toml_config(cfg_path, data)
|
|
317
390
|
print(f"\n✅ Konfigurasi disimpan ke {cfg_path} (izin owner-only).")
|
|
318
391
|
|
|
392
|
+
if not WindowsDriver.detect():
|
|
393
|
+
_install_missing_packages(ask_confirm=True)
|
|
394
|
+
|
|
319
395
|
install_svc = input("Pasang auto-start otomatis saat login? [Y/n]: ").strip().lower()
|
|
320
396
|
if install_svc not in {"n", "no", "tidak"}:
|
|
321
397
|
if _install_autostart():
|
|
@@ -328,7 +404,7 @@ def cmd_setup() -> int:
|
|
|
328
404
|
return 0
|
|
329
405
|
|
|
330
406
|
|
|
331
|
-
def cmd_doctor() -> int:
|
|
407
|
+
def cmd_doctor(install: bool = False) -> int:
|
|
332
408
|
"""Check Python, active driver, and system tool dependencies."""
|
|
333
409
|
print(f"Lapctl v{__version__}")
|
|
334
410
|
print(
|
|
@@ -355,7 +431,7 @@ def cmd_doctor() -> int:
|
|
|
355
431
|
print("\nPemeriksaan dependensi alat:")
|
|
356
432
|
|
|
357
433
|
missing = 0
|
|
358
|
-
for tool, desc, hint in DOCTOR_TOOLS:
|
|
434
|
+
for tool, desc, hint, _ in DOCTOR_TOOLS:
|
|
359
435
|
found = shutil.which(tool) is not None
|
|
360
436
|
status = "OK" if found else "TIDAK ADA"
|
|
361
437
|
print(f" - {tool:<14} [{status:<9}] {desc}")
|
|
@@ -367,6 +443,10 @@ def cmd_doctor() -> int:
|
|
|
367
443
|
print("\nSemua alat tersedia.")
|
|
368
444
|
else:
|
|
369
445
|
print(f"\n{missing} alat opsional/fitur tidak ditemukan.")
|
|
446
|
+
if install:
|
|
447
|
+
_install_missing_packages(ask_confirm=True)
|
|
448
|
+
else:
|
|
449
|
+
print("Jalankan 'lapctl doctor --install' untuk memasang dependensi yang kurang.")
|
|
370
450
|
return 0
|
|
371
451
|
|
|
372
452
|
|
|
@@ -522,7 +602,12 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
522
602
|
sub.add_parser("status", help="Status service dan koneksi Telegram")
|
|
523
603
|
logs_p = sub.add_parser("logs", help="Lihat log terbaru")
|
|
524
604
|
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")
|
|
605
|
+
doc_p = sub.add_parser("doctor", help="Cek dependensi dan kemampuan driver")
|
|
606
|
+
doc_p.add_argument(
|
|
607
|
+
"--install",
|
|
608
|
+
action="store_true",
|
|
609
|
+
help="Tawarkan instalasi otomatis dependensi yang kurang (Linux)",
|
|
610
|
+
)
|
|
526
611
|
|
|
527
612
|
cfg_p = sub.add_parser("config", help="Lihat atau ubah pengaturan")
|
|
528
613
|
cfg_p.add_argument("--change-token", action="store_true", help="Ganti Bot Token Telegram")
|
|
@@ -558,7 +643,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
558
643
|
if args.command == "logs":
|
|
559
644
|
return cmd_logs(lines=args.lines)
|
|
560
645
|
if args.command == "doctor":
|
|
561
|
-
return cmd_doctor()
|
|
646
|
+
return cmd_doctor(install=args.install)
|
|
562
647
|
if args.command == "config":
|
|
563
648
|
return cmd_config(args)
|
|
564
649
|
if args.command == "uninstall":
|
|
@@ -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.
|
|
18
|
+
assert "lapctl 0.1.3" in out
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def test_cli_doctor_reports_missing_tools(monkeypatch, capsys) -> None:
|
|
@@ -88,3 +88,29 @@ 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]
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|