Krolyxon
Commit c98214a

Branches

Refs →

budctlREADME.md

221 lines · 10.6 KB · Markdown

1<div align="center">
2 <img src="docs/logo.svg" width="320" alt="budctl">
3 <p>Control your wireless earbuds from Linux and Android, without the vendor app.</p>
4</div>
5
6Noise control, EQ, game mode, touch controls, battery and more. There is a command-line tool,
7`budctl`, a desktop app, `budctl-gui`, and an [Android app](#android-app), all built on the same
8library.
9
10- No telemetry and no account. budctl talks to your buds over Bluetooth, through BlueZ on Linux.
11 The Android app does not even have the internet permission.
12- The settings live on the buds, so a change made on one device shows on the others.
13
14**Supported buds:** realme Buds T310. More are added as the author gets them.
15
16<p align="center">
17 <img src="docs/screenshots/overview.png" width="560" alt="budctl-gui's Overview page: battery of each bud, noise control, and switches such as game mode and 3D sound">
18</p>
19
20## Install
21
22You need Linux with BlueZ, and for the desktop app a Wayland desktop. Release builds are for
23x86_64 and aarch64 (glibc 2.35 or newer).
24
25```sh
26curl -fsSL https://github.com/krolyxon/budctl/releases/latest/download/install.sh | sh
27```
28
29This puts `budctl` and `budctl-gui` in `~/.local/bin`, and a launcher entry and its icon in
30`~/.local/share`. The download is checked against its SHA-256 checksum. Options:
31
32```sh
33sh install.sh --version 0.1.1 # a given release instead of the latest
34sh install.sh --prefix /usr/local # elsewhere (uses sudo when it must)
35sh install.sh --uninstall # remove them again; your config and log stay
36```
37
38To build from source instead (Rust 1.88 or newer), run `./install.sh --source` in a checkout.
39
40On Arch, `contrib/arch/PKGBUILD` packages the release builds: run `makepkg -si` in that directory.
41
42Pair the buds and connect them in your Bluetooth settings first.
43
44## Command line
45
46```sh
47budctl list # paired buds, and whether budctl knows them
48budctl status # battery, noise control, EQ, switches
49budctl anc off|on|transparency # noise control
50budctl anc light|medium|deep # noise cancelling, at this strength
51budctl eq # the EQ presets, and the one in use
52budctl eq deep-bass # select a preset
53budctl eq custom-4 50=+3 16000=-2 # change bands of a custom preset (dB)
54budctl eq new Gym # create a custom preset: flat, and put to use
55budctl eq rename custom-4 "Gym mix" # rename a custom preset
56budctl eq delete custom-4 # delete a custom preset
57budctl game on|off # game mode (low latency)
58budctl set bass-boost|spatial|wind|dual on|off
59budctl dual # the phones and computers dual connection keeps
60budctl bass low 2 # bass boost, band by band (low, medium, high): -5 to +5
61budctl touch # what each tap and hold does
62budctl touch left triple-tap previous # give a gesture an action (--dry-run first, if you like)
63budctl touch cycle off anc # the modes a hold steps through
64budctl find start --yes # ring the buds (loud: take them out of your ears)
65budctl find stop
66```
67
68- `--json` prints machine-readable output for scripts and status bars (`"schema": 1`).
69- `--debug` hex-dumps every frame sent and received, on stderr.
70- `--device <MAC>` picks the buds when more than one supported pair is connected. Without it,
71 `"device"` in the config file (below) is used, if set.
72
73Exit codes:
74
75| Code | Meaning |
76|---|---|
77| 0 | success |
78| 1 | usage error |
79| 2 | buds not found or not connected |
80| 3 | control channel busy |
81| 4 | the buds rejected the command or did not answer |
82
83## Desktop app
84
85`budctl-gui` has five pages:
86
87- **Overview:** battery, noise control and its strength, the switches, and bass boost band by band
88 (low, medium and high frequencies).
89- **Equalizer:** the presets; create, rename and delete your own, and change their bands.
90- **Gestures:** what each tap and hold does on each bud, and what a hold steps through.
91- **Earbud settings:** dual connection and the devices it keeps, find my earbuds, firmware, audio codec.
92- **App settings:** where the colors come from, the keys, the version.
93
94<table>
95 <tr>
96 <td valign="top"><img src="docs/screenshots/equalizer.png" alt="Equalizer: the built-in presets, a custom preset with its pencil and bin, and its six bands open below"></td>
97 <td valign="top"><img src="docs/screenshots/gestures.png" alt="Gestures: double tap, triple tap and hold for each bud, and the modes a hold steps through"></td>
98 </tr>
99 <tr>
100 <td valign="top"><img src="docs/screenshots/earbuds.png" alt="Earbud settings: the dual connection switch, the devices the buds keep, find my earbuds, firmware and codec"></td>
101 <td valign="top"><img src="docs/screenshots/keys.png" alt="The keys overlay, shown with ?"></td>
102 </tr>
103</table>
104
105The screenshots show `--demo`'s made-up buds.
106
107The app connects when it needs to, and frees the buds' control channel 10 s after your last
108change, so other apps can use it. A change shows "Saving…" until the buds confirm it.
109
110The mouse works everywhere. Vim-like keys work on top of it (press `?` in the window):
111
112| Keys | What they do |
113|---|---|
114| `j` `k`, arrows, Tab | move the cursor |
115| `gg` `G` | first / last item |
116| `h` `l` | previous / next choice, switch off / on; `l` opens a row's page |
117| Enter, Space | toggle, step through the choices, or open |
118| `J` `K`, Ctrl+Tab, `gt` `gT` | next / previous page |
119| `1` … `5` | go to a page |
120| `r` | read the buds again |
121| Esc | hide the cursor |
122| `q` | quit |
123
124The cursor shows only after you press a key, and the first key only shows it.
125
126**Look:** Nothing OS shapes and type in Material You colors: dot-matrix page names and battery
127figures, LED rings and dotted sliders, pill switches and tracks. The fonts (Doto, Space Grotesk,
128Space Mono) are built into the app.
129
130**Colors:** a built-in palette (near-black, white "on" states, red for live things such as the open
131page's dot and "Saving…"), or a [matugen](https://github.com/InioX/matugen) palette: `--theme
132<file>`, else `~/.config/budctl/theme.json`. The file is JSON with Material 3 roles, `on_x` spelled
133`xFg`, all optional: `primary`, `primaryFg`, `primaryContainer`, `primaryContainerFg`, `tertiary`,
134`tertiaryFg`, `surfaceLowest`, `surfaceLow`, `surfaceHigh`, `surfaceHighest`, `surfaceFg`,
135`surfaceVariantFg`, `outline`, `outlineVariant`, `err`, `errFg` (`bg` and `fg` still work for
136`surfaceLowest` and `surfaceFg`; other keys are ignored). A matugen template only needs lines like
137`"primary": "{{colors.primary.default.hex}}"`. The file is read again whenever the window gets
138focus, so a new wallpaper's colors show up there too. When the file is missing, the app writes the
139built-in colors there: a starting point for a template.
140
141**Log:** each launch writes errors and session events (connected, each change and its answer,
142closed) to `~/.local/state/budctl/gui.log`, replacing the last launch's.
143
144Other options: `--demo` shows made-up buds without Bluetooth; `--debug` and `--device` work as in
145the command-line tool.
146
147## Android app
148
149`android/` holds an Android app (Android 12 or newer) with the desktop app's pages and look, on a
150phone: the same Rust library runs inside it, and only the Bluetooth link and the screen are Kotlin.
151Its colors come from your wallpaper (Material You), or from the desktop app's near-black palette.
152
153<p align="center">
154 <img src="docs/screenshots/android-overview.png" width="240" alt="The Android app's Overview: the battery rings, noise control and its strength, and the switches">
155 <img src="docs/screenshots/android-equalizer.png" width="240" alt="The Android app's Equalizer: the presets, and a custom preset's six bands open below">
156 <img src="docs/screenshots/android-gestures.png" width="240" alt="The Android app's Gestures: what each tap and hold does on each bud, and what a hold steps through">
157</p>
158
159The app talks to the buds only while it is on screen, and frees their control channel 10 s after
160your last change or when you leave it, so your computer can use it. It has no internet permission,
161and its build fails if anything adds one. A switch on its App page turns on the debug log, which you
162can copy from there.
163
164To install it, download `budctl.apk` from the
165[latest release](https://github.com/krolyxon/budctl/releases/latest) on your phone and open it
166(Android asks you to allow installs from your browser or file manager). New versions come out as
167new releases: an app such as Obtainium can watch them for you, since budctl itself never checks.
168The APK is signed with budctl's own key. Its certificate's SHA-256 fingerprint is
169`45:6F:9B:93:AA:40:1D:57:AA:6C:75:0D:FF:13:FA:82:5A:7B:28:B6:3D:D0:40:99:80:6F:A9:7C:14:75:23:12`.
170
171To build it yourself instead and put it on your phone (with USB debugging on), you need Android
172Studio or the Android SDK with its NDK, the Rust targets
173(`rustup target add aarch64-linux-android x86_64-linux-android`) and `cargo install cargo-ndk`:
174
175```sh
176cd android
177./gradlew installDebug
178```
179
180A build of your own is signed with your machine's debug key, so Android will not install a release
181over it, or the other way round: uninstall one before installing the other.
182
183How it is put together: [`docs/android.md`](docs/android.md). The screenshots show made-up buds
184(`adb shell am start -n io.github.krolyxon.budctl/.MainActivity --ez demo true`).
185
186## Config
187
188`~/.config/budctl/config.json` is created with the defaults the first time it is needed. Every key
189is optional; a file with a mistake is reported and the defaults are used.
190
191```json
192{
193 "device": null,
194 "gui": {
195 "idle_seconds": 10,
196 "start_page": "overview",
197 "motion": true
198 }
199}
200```
201
202- `device`: the buds to use when `--device` is not given, as `"AA:BB:CC:DD:EE:FF"`.
203- `gui.idle_seconds`: how long the app keeps the control channel open after the last change
204 (1–600).
205- `gui.start_page`: `overview`, `equalizer`, `gestures`, `earbuds` or `settings`.
206- `gui.motion`: `false` turns the app's animations off; every change then shows at once.
207
208## How it works
209
210budctl speaks the buds' own control protocol over an RFCOMM socket. What is known about it, and
211how sure, is written down in [`docs/protocol/`](docs/protocol/): the
212[transport](docs/protocol/transport.md) and the [realme Buds T310](docs/protocol/realme_t310.md).
213
214## License
215
216GPL-3.0-or-later. See [LICENSE](LICENSE).
217
218The desktop and Android apps carry the Doto, Space Grotesk and Space Mono fonts, under the SIL
219Open Font License 1.1 ([`crates/budctl-gui/fonts/OFL.txt`](crates/budctl-gui/fonts/OFL.txt)). The
220Doto in them is a static instance (rounded dots, black weight, Latin only), renamed "Doto Rounded"
221as the license asks of modified fonts.