lapctl 0.1.1__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.1/src/lapctl.egg-info → lapctl-0.1.3}/PKG-INFO +13 -7
- {lapctl-0.1.1 → lapctl-0.1.3}/README.md +11 -5
- {lapctl-0.1.1 → lapctl-0.1.3}/pyproject.toml +2 -2
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/__init__.py +1 -1
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/channels/telegram/handlers.py +4 -1
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/channels/telegram/poller.py +3 -1
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/cli.py +157 -27
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/core/commands.py +6 -4
- lapctl-0.1.3/src/lapctl/core/keyboards.py +226 -0
- lapctl-0.1.3/src/lapctl/drivers/__init__.py +14 -0
- lapctl-0.1.3/src/lapctl/drivers/windows.py +433 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/main.py +2 -2
- {lapctl-0.1.1 → lapctl-0.1.3/src/lapctl.egg-info}/PKG-INFO +13 -7
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl.egg-info/SOURCES.txt +3 -1
- lapctl-0.1.3/tests/test_cli.py +116 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/tests/test_registry_and_profiles.py +15 -1
- {lapctl-0.1.1 → lapctl-0.1.3}/tests/test_render_and_driver.py +36 -0
- lapctl-0.1.3/tests/test_windows_driver.py +65 -0
- lapctl-0.1.1/src/lapctl/core/keyboards.py +0 -140
- lapctl-0.1.1/src/lapctl/drivers/__init__.py +0 -1
- lapctl-0.1.1/tests/test_cli.py +0 -62
- {lapctl-0.1.1 → lapctl-0.1.3}/LICENSE +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/setup.cfg +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/channels/__init__.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/channels/telegram/__init__.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/channels/telegram/api.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/channels/telegram/auth.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/channels/telegram/render.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/config.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/core/__init__.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/core/battery.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/core/confirm.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/core/paths.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/core/ratelimit.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/drivers/base.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/drivers/linux_hyprland.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/registry.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl/results.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl.egg-info/dependency_links.txt +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl.egg-info/entry_points.txt +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl.egg-info/requires.txt +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/src/lapctl.egg-info/top_level.txt +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/tests/test_auth_and_config.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/tests/test_confirm.py +0 -0
- {lapctl-0.1.1 → lapctl-0.1.3}/tests/test_paths.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lapctl
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Open-source laptop remote control agent via Telegram
|
|
5
|
-
License: MIT
|
|
5
|
+
License-Expression: MIT
|
|
6
6
|
Requires-Python: >=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
License-File: LICENSE
|
|
@@ -12,12 +12,16 @@ Requires-Dist: pytest>=8.0; extra == "dev"
|
|
|
12
12
|
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
13
13
|
Dynamic: license-file
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="docs/image.png" alt="Lapctl" width="640" />
|
|
17
|
+
</p>
|
|
16
18
|
|
|
17
19
|
Agent open source yang berjalan di laptop untuk mengendalikan laptop dari jarak jauh melalui Telegram (kunci layar, screenshot, kamera, kontrol media, cek status, file, dan kontrol daya) tanpa server tambahan dan tanpa membuka port jaringan masuk.
|
|
18
20
|
|
|
19
21
|
## Privasi dan Keamanan
|
|
20
22
|
|
|
23
|
+
- **100% Open Source ([Lisensi MIT](LICENSE)):** seluruh kode sumber terbuka dan dapat diperiksa/diaudit oleh siapa saja.
|
|
24
|
+
- **Berjalan di laptop lokal masing-masing:** agent ini berjalan langsung di laptop/PC milik kamu sendiri menggunakan bot Telegram milikmu sendiri, **bukan di server milik developer**. Developer tidak memiliki akses ke token, perintah, file, maupun laptop kamu.
|
|
21
25
|
- Pesan, screenshot, foto, dan file **melewati server Telegram**. Bot API tidak terenkripsi end-to-end. Pertimbangkan hal ini sebelum memakai fitur sensitif.
|
|
22
26
|
- Lapctl tidak memiliki server, akun, atau telemetri.
|
|
23
27
|
- Panggilan jaringan selain ke `api.telegram.org` hanya terjadi pada fitur eksternal yang diaktifkan sendiri oleh pengguna (TTS via Google Translate, geolokasi IP via `ip-api.com`, atau notifikasi `ntfy`).
|
|
@@ -26,7 +30,7 @@ Agent open source yang berjalan di laptop untuk mengendalikan laptop dari jarak
|
|
|
26
30
|
## Prasyarat
|
|
27
31
|
|
|
28
32
|
- **Python 3.11** atau lebih baru
|
|
29
|
-
- **OS:** Linux (
|
|
33
|
+
- **OS:** Linux (Wayland/Hyprland) dan **Windows 10/11** (driver X11 & macOS direncanakan berikutnya)
|
|
30
34
|
- **pipx** (tool untuk menginstal aplikasi CLI Python secara terisolasi tanpa mengganggu Python sistem)
|
|
31
35
|
|
|
32
36
|
### Cara Pasang `pipx`
|
|
@@ -58,10 +62,10 @@ python -m pipx ensurepath
|
|
|
58
62
|
|
|
59
63
|
## Cara Instalasi
|
|
60
64
|
|
|
61
|
-
### Opsi 1:
|
|
65
|
+
### Opsi 1: Via `pipx` (Direkomendasikan)
|
|
62
66
|
|
|
63
67
|
```bash
|
|
64
|
-
pipx install
|
|
68
|
+
pipx install lapctl
|
|
65
69
|
```
|
|
66
70
|
|
|
67
71
|
Untuk memperbarui ke versi terbaru nanti:
|
|
@@ -109,7 +113,7 @@ pip install .
|
|
|
109
113
|
| `lapctl stop` / `restart` | Hentikan atau mulai ulang service systemd user |
|
|
110
114
|
| `lapctl status` | Cek status service dan koneksi ke Telegram |
|
|
111
115
|
| `lapctl logs` | Lihat log terbaru dari service |
|
|
112
|
-
| `lapctl config` | Lihat atau ubah pengaturan (`--profile`, `--language`, `--device-name`, `--ntfy-topic`) |
|
|
116
|
+
| `lapctl config` | Lihat atau ubah pengaturan (`--change-token`, `--profile`, `--language`, `--device-name`, `--ntfy-topic`) |
|
|
113
117
|
| `lapctl uninstall` | Hapus service dan file konfigurasi |
|
|
114
118
|
| `lapctl --version` | Tampilkan versi |
|
|
115
119
|
|
|
@@ -123,6 +127,8 @@ pip install .
|
|
|
123
127
|
|
|
124
128
|
## Daftar Perintah Telegram
|
|
125
129
|
|
|
130
|
+
`/menu` menampilkan menu kategori ringkas dengan nama perangkat (`device_name`) dan otomatis menghapus pesan tombol sebelumnya saat berpindah kategori atau menekan tombol konfirmasi agar riwayat chat tetap bersih.
|
|
131
|
+
|
|
126
132
|
| Kategori | Perintah | Risiko | Profil minimum |
|
|
127
133
|
|---|---|---|---|
|
|
128
134
|
| Navigasi | `/start`, `/help`, `/menu` | R | aman |
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/image.png" alt="Lapctl" width="640" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
5
|
Agent open source yang berjalan di laptop untuk mengendalikan laptop dari jarak jauh melalui Telegram (kunci layar, screenshot, kamera, kontrol media, cek status, file, dan kontrol daya) tanpa server tambahan dan tanpa membuka port jaringan masuk.
|
|
4
6
|
|
|
5
7
|
## Privasi dan Keamanan
|
|
6
8
|
|
|
9
|
+
- **100% Open Source ([Lisensi MIT](LICENSE)):** seluruh kode sumber terbuka dan dapat diperiksa/diaudit oleh siapa saja.
|
|
10
|
+
- **Berjalan di laptop lokal masing-masing:** agent ini berjalan langsung di laptop/PC milik kamu sendiri menggunakan bot Telegram milikmu sendiri, **bukan di server milik developer**. Developer tidak memiliki akses ke token, perintah, file, maupun laptop kamu.
|
|
7
11
|
- Pesan, screenshot, foto, dan file **melewati server Telegram**. Bot API tidak terenkripsi end-to-end. Pertimbangkan hal ini sebelum memakai fitur sensitif.
|
|
8
12
|
- Lapctl tidak memiliki server, akun, atau telemetri.
|
|
9
13
|
- Panggilan jaringan selain ke `api.telegram.org` hanya terjadi pada fitur eksternal yang diaktifkan sendiri oleh pengguna (TTS via Google Translate, geolokasi IP via `ip-api.com`, atau notifikasi `ntfy`).
|
|
@@ -12,7 +16,7 @@ Agent open source yang berjalan di laptop untuk mengendalikan laptop dari jarak
|
|
|
12
16
|
## Prasyarat
|
|
13
17
|
|
|
14
18
|
- **Python 3.11** atau lebih baru
|
|
15
|
-
- **OS:** Linux (
|
|
19
|
+
- **OS:** Linux (Wayland/Hyprland) dan **Windows 10/11** (driver X11 & macOS direncanakan berikutnya)
|
|
16
20
|
- **pipx** (tool untuk menginstal aplikasi CLI Python secara terisolasi tanpa mengganggu Python sistem)
|
|
17
21
|
|
|
18
22
|
### Cara Pasang `pipx`
|
|
@@ -44,10 +48,10 @@ python -m pipx ensurepath
|
|
|
44
48
|
|
|
45
49
|
## Cara Instalasi
|
|
46
50
|
|
|
47
|
-
### Opsi 1:
|
|
51
|
+
### Opsi 1: Via `pipx` (Direkomendasikan)
|
|
48
52
|
|
|
49
53
|
```bash
|
|
50
|
-
pipx install
|
|
54
|
+
pipx install lapctl
|
|
51
55
|
```
|
|
52
56
|
|
|
53
57
|
Untuk memperbarui ke versi terbaru nanti:
|
|
@@ -95,7 +99,7 @@ pip install .
|
|
|
95
99
|
| `lapctl stop` / `restart` | Hentikan atau mulai ulang service systemd user |
|
|
96
100
|
| `lapctl status` | Cek status service dan koneksi ke Telegram |
|
|
97
101
|
| `lapctl logs` | Lihat log terbaru dari service |
|
|
98
|
-
| `lapctl config` | Lihat atau ubah pengaturan (`--profile`, `--language`, `--device-name`, `--ntfy-topic`) |
|
|
102
|
+
| `lapctl config` | Lihat atau ubah pengaturan (`--change-token`, `--profile`, `--language`, `--device-name`, `--ntfy-topic`) |
|
|
99
103
|
| `lapctl uninstall` | Hapus service dan file konfigurasi |
|
|
100
104
|
| `lapctl --version` | Tampilkan versi |
|
|
101
105
|
|
|
@@ -109,6 +113,8 @@ pip install .
|
|
|
109
113
|
|
|
110
114
|
## Daftar Perintah Telegram
|
|
111
115
|
|
|
116
|
+
`/menu` menampilkan menu kategori ringkas dengan nama perangkat (`device_name`) dan otomatis menghapus pesan tombol sebelumnya saat berpindah kategori atau menekan tombol konfirmasi agar riwayat chat tetap bersih.
|
|
117
|
+
|
|
112
118
|
| Kategori | Perintah | Risiko | Profil minimum |
|
|
113
119
|
|---|---|---|---|
|
|
114
120
|
| Navigasi | `/start`, `/help`, `/menu` | R | aman |
|
|
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "lapctl"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.3"
|
|
8
8
|
description = "Open-source laptop remote control agent via Telegram"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
license =
|
|
10
|
+
license = "MIT"
|
|
11
11
|
requires-python = ">=3.11"
|
|
12
12
|
dependencies = [
|
|
13
13
|
"requests>=2.31",
|
|
@@ -156,6 +156,9 @@ class TelegramHandlers:
|
|
|
156
156
|
cb_data: str,
|
|
157
157
|
username: str,
|
|
158
158
|
owner_id: int = 0,
|
|
159
|
+
message_id: int | None = None,
|
|
159
160
|
) -> None:
|
|
160
|
-
"""
|
|
161
|
+
"""Delete previous inline message (unless no-op) and dispatch callback."""
|
|
162
|
+
if message_id is not None and cb_data.strip().lower() != "/none":
|
|
163
|
+
self.client.delete_message(chat_id, message_id)
|
|
161
164
|
self._run_and_render(chat_id, cb_data, owner_id=owner_id)
|
|
@@ -24,7 +24,7 @@ class TelegramPoller:
|
|
|
24
24
|
on_text: Callable[[int | str, str, int | None, str, int], None],
|
|
25
25
|
on_document: Callable[[int | str, str, str, str, int], None],
|
|
26
26
|
on_photo: Callable[[int | str, str, str, str, int], None],
|
|
27
|
-
on_callback: Callable[[int | str, str, str, int], None],
|
|
27
|
+
on_callback: Callable[[int | str, str, str, int, int | None], None],
|
|
28
28
|
on_before_update: Callable[[], None] | None = None,
|
|
29
29
|
max_workers: int = 4,
|
|
30
30
|
) -> None:
|
|
@@ -108,6 +108,7 @@ class TelegramPoller:
|
|
|
108
108
|
|
|
109
109
|
self.client.answer_callback_query(cb["id"])
|
|
110
110
|
username = cb.get("from", {}).get("username", "Unknown")
|
|
111
|
+
message_id = msg.get("message_id")
|
|
111
112
|
self._dispatch(
|
|
112
113
|
async_dispatch,
|
|
113
114
|
self.on_callback,
|
|
@@ -115,6 +116,7 @@ class TelegramPoller:
|
|
|
115
116
|
cb_data,
|
|
116
117
|
username,
|
|
117
118
|
sender_id,
|
|
119
|
+
message_id,
|
|
118
120
|
)
|
|
119
121
|
|
|
120
122
|
def _dispatch(self, async_dispatch: bool, fn: Callable[..., None], *args: Any) -> None:
|
|
@@ -25,15 +25,19 @@ from lapctl.config import (
|
|
|
25
25
|
get_owner_id,
|
|
26
26
|
write_toml_config,
|
|
27
27
|
)
|
|
28
|
+
from lapctl.drivers import get_active_driver
|
|
28
29
|
from lapctl.drivers.linux_hyprland import LinuxHyprlandDriver
|
|
30
|
+
from lapctl.drivers.windows import WindowsDriver
|
|
29
31
|
from lapctl.main import main as run_agent
|
|
30
32
|
|
|
31
33
|
SERVICE_NAME = "lapctl.service"
|
|
32
34
|
|
|
33
35
|
BANNER_PARTS: list[tuple[str, str]] = [
|
|
34
|
-
("
|
|
35
|
-
("
|
|
36
|
-
("
|
|
36
|
+
("░██░░░░░░█████░░██████░░", "░██████░██████░██░░░░░"),
|
|
37
|
+
("░██░░░░░██░░░██░██░░░██░", "██░░░░░░░░██░░░██░░░░░"),
|
|
38
|
+
("░██░░░░░███████░██████░░", "██░░░░░░░░██░░░██░░░░░"),
|
|
39
|
+
("░██░░░░░██░░░██░██░░░░░░", "██░░░░░░░░██░░░██░░░░░"),
|
|
40
|
+
("░██████░██░░░██░██░░░░░░", "░██████░░░██░░░██████░"),
|
|
37
41
|
]
|
|
38
42
|
|
|
39
43
|
|
|
@@ -52,66 +56,139 @@ def print_banner() -> None:
|
|
|
52
56
|
print()
|
|
53
57
|
|
|
54
58
|
|
|
55
|
-
DOCTOR_TOOLS: list[tuple[str, str, str]] = [
|
|
56
|
-
(
|
|
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
|
+
),
|
|
57
66
|
(
|
|
58
67
|
"ffmpeg",
|
|
59
68
|
"Webcam & audio (/cam, /vid, /record)",
|
|
60
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"},
|
|
61
77
|
),
|
|
62
|
-
("
|
|
63
|
-
("
|
|
64
|
-
("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", {}),
|
|
65
80
|
(
|
|
66
81
|
"wpctl",
|
|
67
82
|
"Kontrol volume & mute",
|
|
68
83
|
"sudo pacman -S wireplumber | sudo apt install wireplumber",
|
|
84
|
+
{"pacman": "wireplumber", "apt": "wireplumber", "dnf": "wireplumber"},
|
|
69
85
|
),
|
|
70
86
|
(
|
|
71
87
|
"brightnessctl",
|
|
72
88
|
"Kecerahan layar (/brightness)",
|
|
73
89
|
"sudo pacman -S brightnessctl | sudo apt install brightnessctl",
|
|
90
|
+
{"pacman": "brightnessctl", "apt": "brightnessctl", "dnf": "brightnessctl"},
|
|
74
91
|
),
|
|
75
92
|
(
|
|
76
93
|
"playerctl",
|
|
77
94
|
"Kontrol media (/play, /pause, /next)",
|
|
78
95
|
"sudo pacman -S playerctl | sudo apt install playerctl",
|
|
96
|
+
{"pacman": "playerctl", "apt": "playerctl", "dnf": "playerctl"},
|
|
79
97
|
),
|
|
80
98
|
(
|
|
81
99
|
"wl-copy",
|
|
82
100
|
"Clipboard tulis (/setclip)",
|
|
83
101
|
"sudo pacman -S wl-clipboard | sudo apt install wl-clipboard",
|
|
102
|
+
{"pacman": "wl-clipboard", "apt": "wl-clipboard", "dnf": "wl-clipboard"},
|
|
84
103
|
),
|
|
85
104
|
(
|
|
86
105
|
"wl-paste",
|
|
87
106
|
"Clipboard baca (/getclip)",
|
|
88
107
|
"sudo pacman -S wl-clipboard | sudo apt install wl-clipboard",
|
|
108
|
+
{"pacman": "wl-clipboard", "apt": "wl-clipboard", "dnf": "wl-clipboard"},
|
|
89
109
|
),
|
|
90
|
-
("swww", "Wallpaper (/wallpaper)", "sudo pacman -S swww"),
|
|
110
|
+
("swww", "Wallpaper (/wallpaper)", "sudo pacman -S swww", {"pacman": "swww"}),
|
|
91
111
|
(
|
|
92
112
|
"notify-send",
|
|
93
113
|
"Notifikasi desktop (/notify)",
|
|
94
114
|
"sudo pacman -S libnotify | sudo apt install libnotify-bin",
|
|
115
|
+
{"pacman": "libnotify", "apt": "libnotify-bin", "dnf": "libnotify"},
|
|
95
116
|
),
|
|
96
117
|
(
|
|
97
118
|
"xdotool",
|
|
98
119
|
"Input mouse/keyboard (/mouse, /keyboard)",
|
|
99
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"},
|
|
100
128
|
),
|
|
101
|
-
("mpv", "Pemutar TTS (/say)", "sudo pacman -S mpv | sudo apt install mpv"),
|
|
102
129
|
(
|
|
103
130
|
"paplay",
|
|
104
131
|
"Suara beep (/beep)",
|
|
105
132
|
"sudo pacman -S libpulse | sudo apt install pulseaudio-utils",
|
|
133
|
+
{"pacman": "libpulse", "apt": "pulseaudio-utils", "dnf": "pulseaudio-utils"},
|
|
106
134
|
),
|
|
107
135
|
(
|
|
108
136
|
"nmcli",
|
|
109
137
|
"Info WiFi (/status)",
|
|
110
138
|
"sudo pacman -S networkmanager | sudo apt install network-manager",
|
|
139
|
+
{"pacman": "networkmanager", "apt": "network-manager", "dnf": "NetworkManager"},
|
|
111
140
|
),
|
|
112
141
|
]
|
|
113
142
|
|
|
114
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
|
+
|
|
115
192
|
def _systemd_service_path() -> Path:
|
|
116
193
|
xdg = os.environ.get("XDG_CONFIG_HOME")
|
|
117
194
|
base = Path(xdg) if xdg else Path.home() / ".config"
|
|
@@ -168,8 +245,21 @@ def _wait_for_owner_message(
|
|
|
168
245
|
return None
|
|
169
246
|
|
|
170
247
|
|
|
171
|
-
def
|
|
172
|
-
"""Create and enable
|
|
248
|
+
def _install_autostart() -> bool:
|
|
249
|
+
"""Create and enable OS-appropriate auto-start service."""
|
|
250
|
+
if WindowsDriver.detect() and shutil.which("schtasks") is not None:
|
|
251
|
+
exe = shutil.which("lapctl") or f'"{sys.executable}" -m lapctl.cli'
|
|
252
|
+
tr = f'"{exe}" start' if " " not in exe else f"{exe} start"
|
|
253
|
+
try:
|
|
254
|
+
subprocess.run(
|
|
255
|
+
["schtasks", "/Create", "/TN", "Lapctl", "/TR", tr, "/SC", "ONLOGON", "/F"],
|
|
256
|
+
check=True,
|
|
257
|
+
timeout=10,
|
|
258
|
+
)
|
|
259
|
+
return True
|
|
260
|
+
except Exception:
|
|
261
|
+
return False
|
|
262
|
+
|
|
173
263
|
if not sys.platform.startswith("linux") or shutil.which("systemctl") is None:
|
|
174
264
|
return False
|
|
175
265
|
|
|
@@ -207,10 +297,9 @@ def cmd_setup() -> int:
|
|
|
207
297
|
"""Interactive setup wizard for first-time configuration."""
|
|
208
298
|
print_banner()
|
|
209
299
|
print(f"Python: {sys.version.split()[0]} | Platform: {sys.platform}")
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
)
|
|
300
|
+
driver = get_active_driver()
|
|
301
|
+
detected = driver.name if driver.detect() else "belum terdeteksi (mode generik)"
|
|
302
|
+
print(f"Driver terdeteksi: {detected}")
|
|
214
303
|
|
|
215
304
|
cfg_path = default_config_path()
|
|
216
305
|
if cfg_path.exists():
|
|
@@ -300,36 +389,49 @@ def cmd_setup() -> int:
|
|
|
300
389
|
write_toml_config(cfg_path, data)
|
|
301
390
|
print(f"\n✅ Konfigurasi disimpan ke {cfg_path} (izin owner-only).")
|
|
302
391
|
|
|
303
|
-
|
|
392
|
+
if not WindowsDriver.detect():
|
|
393
|
+
_install_missing_packages(ask_confirm=True)
|
|
394
|
+
|
|
395
|
+
install_svc = input("Pasang auto-start otomatis saat login? [Y/n]: ").strip().lower()
|
|
304
396
|
if install_svc not in {"n", "no", "tidak"}:
|
|
305
|
-
if
|
|
306
|
-
print(
|
|
397
|
+
if _install_autostart():
|
|
398
|
+
print("✅ Auto-start berhasil dipasang.")
|
|
307
399
|
else:
|
|
308
|
-
print("⚠️ Gagal memasang
|
|
400
|
+
print("⚠️ Gagal memasang auto-start otomatis. Jalankan manual dengan: lapctl start")
|
|
309
401
|
|
|
310
402
|
client.send_message(owner_id, "Terhubung ✅")
|
|
311
403
|
print("\nSetup selesai! Kirim /menu ke bot Anda di Telegram.")
|
|
312
404
|
return 0
|
|
313
405
|
|
|
314
406
|
|
|
315
|
-
def cmd_doctor() -> int:
|
|
407
|
+
def cmd_doctor(install: bool = False) -> int:
|
|
316
408
|
"""Check Python, active driver, and system tool dependencies."""
|
|
317
409
|
print(f"Lapctl v{__version__}")
|
|
318
410
|
print(
|
|
319
411
|
f"Python: {sys.version.split()[0]} ({'OK' if sys.version_info >= (3, 11) else 'Perlu >= 3.11'})"
|
|
320
412
|
)
|
|
321
413
|
print(f"Platform: {sys.platform}")
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
414
|
+
if WindowsDriver.detect():
|
|
415
|
+
print("Driver aktif: windows (menggunakan PowerShell/.NET bawaan)")
|
|
416
|
+
else:
|
|
417
|
+
print(
|
|
418
|
+
f"Driver linux_hyprland: {'terdeteksi' if LinuxHyprlandDriver.detect() else 'tidak terdeteksi'}"
|
|
419
|
+
)
|
|
325
420
|
cfg_path = default_config_path()
|
|
326
421
|
print(
|
|
327
422
|
f"Konfigurasi ({cfg_path}): {'ada' if cfg_path.exists() else 'belum ada (jalankan lapctl setup)'}"
|
|
328
423
|
)
|
|
424
|
+
if WindowsDriver.detect():
|
|
425
|
+
has_ffmpeg = shutil.which("ffmpeg") is not None
|
|
426
|
+
has_mpv = shutil.which("mpv") is not None
|
|
427
|
+
print("\nPemeriksaan alat opsional Windows:")
|
|
428
|
+
print(f" - ffmpeg [{'OK' if has_ffmpeg else 'TIDAK ADA'}] Rekam layar (/screenrecord)")
|
|
429
|
+
print(f" - mpv [{'OK' if has_mpv else 'TIDAK ADA'}] TTS (/say)")
|
|
430
|
+
return 0
|
|
329
431
|
print("\nPemeriksaan dependensi alat:")
|
|
330
432
|
|
|
331
433
|
missing = 0
|
|
332
|
-
for tool, desc, hint in DOCTOR_TOOLS:
|
|
434
|
+
for tool, desc, hint, _ in DOCTOR_TOOLS:
|
|
333
435
|
found = shutil.which(tool) is not None
|
|
334
436
|
status = "OK" if found else "TIDAK ADA"
|
|
335
437
|
print(f" - {tool:<14} [{status:<9}] {desc}")
|
|
@@ -341,6 +443,10 @@ def cmd_doctor() -> int:
|
|
|
341
443
|
print("\nSemua alat tersedia.")
|
|
342
444
|
else:
|
|
343
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.")
|
|
344
450
|
return 0
|
|
345
451
|
|
|
346
452
|
|
|
@@ -408,6 +514,24 @@ def cmd_config(args: argparse.Namespace) -> int:
|
|
|
408
514
|
cfg = tomllib.load(f)
|
|
409
515
|
|
|
410
516
|
changed = False
|
|
517
|
+
if getattr(args, "change_token", False):
|
|
518
|
+
try:
|
|
519
|
+
new_token = getpass.getpass("Masukkan Bot Token baru (input disembunyikan): ").strip()
|
|
520
|
+
except (KeyboardInterrupt, EOFError):
|
|
521
|
+
print("\nDibatalkan.")
|
|
522
|
+
return 1
|
|
523
|
+
if not new_token:
|
|
524
|
+
print("❌ Token tidak boleh kosong.")
|
|
525
|
+
return 1
|
|
526
|
+
client = TelegramClient(new_token)
|
|
527
|
+
info = client.get_me()
|
|
528
|
+
if not info:
|
|
529
|
+
print("❌ Token baru tidak valid atau gagal menghubungi api.telegram.org.")
|
|
530
|
+
return 1
|
|
531
|
+
client.delete_webhook(drop_pending_updates=False)
|
|
532
|
+
cfg.setdefault("telegram", {})["bot_token"] = new_token
|
|
533
|
+
changed = True
|
|
534
|
+
print(f"✅ Token terhubung ke bot @{info.get('username', 'unknown')}.")
|
|
411
535
|
if args.profile:
|
|
412
536
|
cfg.setdefault("general", {})["profile"] = args.profile
|
|
413
537
|
changed = True
|
|
@@ -478,9 +602,15 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
478
602
|
sub.add_parser("status", help="Status service dan koneksi Telegram")
|
|
479
603
|
logs_p = sub.add_parser("logs", help="Lihat log terbaru")
|
|
480
604
|
logs_p.add_argument("-n", "--lines", type=int, default=30, help="Jumlah baris log")
|
|
481
|
-
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
|
+
)
|
|
482
611
|
|
|
483
612
|
cfg_p = sub.add_parser("config", help="Lihat atau ubah pengaturan")
|
|
613
|
+
cfg_p.add_argument("--change-token", action="store_true", help="Ganti Bot Token Telegram")
|
|
484
614
|
cfg_p.add_argument("--profile", choices=["aman", "standar", "lengkap"])
|
|
485
615
|
cfg_p.add_argument("--language", choices=["id", "en"])
|
|
486
616
|
cfg_p.add_argument("--device-name")
|
|
@@ -513,7 +643,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
513
643
|
if args.command == "logs":
|
|
514
644
|
return cmd_logs(lines=args.lines)
|
|
515
645
|
if args.command == "doctor":
|
|
516
|
-
return cmd_doctor()
|
|
646
|
+
return cmd_doctor(install=args.install)
|
|
517
647
|
if args.command == "config":
|
|
518
648
|
return cmd_config(args)
|
|
519
649
|
if args.command == "uninstall":
|
|
@@ -13,7 +13,7 @@ import requests
|
|
|
13
13
|
|
|
14
14
|
from lapctl.core.confirm import ConfirmationManager
|
|
15
15
|
from lapctl.core.keyboards import (
|
|
16
|
-
|
|
16
|
+
get_menu_content,
|
|
17
17
|
get_start_buttons,
|
|
18
18
|
get_status_buttons,
|
|
19
19
|
)
|
|
@@ -275,10 +275,12 @@ def _cmd_status(ctx: CommandContext) -> CommandOutput:
|
|
|
275
275
|
|
|
276
276
|
|
|
277
277
|
def _cmd_menu(ctx: CommandContext) -> CommandOutput:
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
header, rows = get_menu_content(
|
|
279
|
+
registry=ctx.registry,
|
|
280
|
+
config=ctx.config,
|
|
281
|
+
section=ctx.args,
|
|
281
282
|
)
|
|
283
|
+
return Buttons(text=header, rows=rows)
|
|
282
284
|
|
|
283
285
|
|
|
284
286
|
def _cmd_none(ctx: CommandContext) -> CommandOutput:
|