poor-mans-macropad 0.1.0__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.
- poor_mans_macropad-0.1.0/LICENSE +21 -0
- poor_mans_macropad-0.1.0/PKG-INFO +541 -0
- poor_mans_macropad-0.1.0/README.md +512 -0
- poor_mans_macropad-0.1.0/pyproject.toml +60 -0
- poor_mans_macropad-0.1.0/src/macropad/README.md +410 -0
- poor_mans_macropad-0.1.0/src/macropad/__init__.py +8 -0
- poor_mans_macropad-0.1.0/src/macropad/__main__.py +4 -0
- poor_mans_macropad-0.1.0/src/macropad/actions.py +130 -0
- poor_mans_macropad-0.1.0/src/macropad/assets/macropad.svg +18 -0
- poor_mans_macropad-0.1.0/src/macropad/cli/__init__.py +161 -0
- poor_mans_macropad-0.1.0/src/macropad/cli/doctor.py +26 -0
- poor_mans_macropad-0.1.0/src/macropad/cli/init.py +234 -0
- poor_mans_macropad-0.1.0/src/macropad/cli/listen.py +180 -0
- poor_mans_macropad-0.1.0/src/macropad/cli/monitor.py +99 -0
- poor_mans_macropad-0.1.0/src/macropad/cli/profile_files.py +63 -0
- poor_mans_macropad-0.1.0/src/macropad/cli/service.py +159 -0
- poor_mans_macropad-0.1.0/src/macropad/cli/status.py +46 -0
- poor_mans_macropad-0.1.0/src/macropad/cli/validate.py +18 -0
- poor_mans_macropad-0.1.0/src/macropad/config.py +127 -0
- poor_mans_macropad-0.1.0/src/macropad/diagnostics.py +290 -0
- poor_mans_macropad-0.1.0/src/macropad/handlers.py +286 -0
- poor_mans_macropad-0.1.0/src/macropad/interceptor.py +391 -0
- poor_mans_macropad-0.1.0/src/macropad/logging_config.py +48 -0
- poor_mans_macropad-0.1.0/src/macropad/notifications.py +38 -0
- poor_mans_macropad-0.1.0/src/macropad/profile_watcher.py +87 -0
- poor_mans_macropad-0.1.0/src/macropad/profiles.py +458 -0
- poor_mans_macropad-0.1.0/src/macropad/runtime_status.py +263 -0
- poor_mans_macropad-0.1.0/src/macropad/service_unit.py +133 -0
- poor_mans_macropad-0.1.0/src/macropad/supervisor.py +321 -0
- poor_mans_macropad-0.1.0/src/macropad/validation.py +91 -0
- poor_mans_macropad-0.1.0/src/macropad/worker.py +75 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rafael Glikis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: poor-mans-macropad
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Turn every keyboard into a Macropad
|
|
5
|
+
Keywords: evdev,keyboard,linux,macropad
|
|
6
|
+
Author: Rafael Glikis
|
|
7
|
+
Author-email: Rafael Glikis <rafaelglikis@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Requires-Dist: dbus-python>=1.3.2
|
|
20
|
+
Requires-Dist: evdev>=1.6.1
|
|
21
|
+
Requires-Dist: notify2>=0.3.1
|
|
22
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
23
|
+
Requires-Dist: watchdog>=3.0.0
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Project-URL: Homepage, https://github.com/rafaelglikis/macropad
|
|
26
|
+
Project-URL: Issues, https://github.com/rafaelglikis/macropad/issues
|
|
27
|
+
Project-URL: Repository, https://github.com/rafaelglikis/macropad
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# Macropad
|
|
31
|
+
|
|
32
|
+
[](https://github.com/rafaelglikis/macropad/actions/workflows/ci.yml)
|
|
33
|
+
|
|
34
|
+
Turn every keyboard into a macropad.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
Install the system dependencies required to build the Python DBus bindings:
|
|
39
|
+
|
|
40
|
+
Debian/Ubuntu:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
sudo apt install libdbus-1-dev libglib2.0-dev
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Fedora:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
sudo dnf install dbus-devel glib2-devel
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Install Macropad as an isolated user command with `uv`:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv tool install poor-mans-macropad
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The distribution is named `poor-mans-macropad`; the installed command remains `macropad`. `pipx`
|
|
59
|
+
is also supported:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pipx install poor-mans-macropad
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Confirm the installed version:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
macropad --version
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
Listen using profiles from the default configuration directory:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
macropad listen
|
|
77
|
+
macropad --verbose listen
|
|
78
|
+
macropad --debug listen
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Validate profiles without opening or grabbing input devices:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
macropad validate
|
|
85
|
+
macropad validate profile.yml
|
|
86
|
+
macropad validate --directory ./profiles
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Check input permissions, profile access, and the runtime environment:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
macropad doctor
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Inspect live keyboard worker and device state:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
macropad status
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Create a first profile through guided device and key detection:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
macropad init
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
List readable input devices and stream key names without grabbing the keyboard:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
macropad monitor
|
|
111
|
+
macropad monitor 'Exact Device Name'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The module entry point is also available:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
python -m macropad --help
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Profile Format
|
|
121
|
+
|
|
122
|
+
Macropad loads `.yml` files from `$XDG_CONFIG_HOME/macropad/profiles/`, defaulting to
|
|
123
|
+
`~/.config/macropad/profiles/` when `XDG_CONFIG_HOME` is unset or relative. A profile uses the strict
|
|
124
|
+
version 1 format and names a keyboard exactly as Linux evdev reports it:
|
|
125
|
+
|
|
126
|
+
When a custom absolute `XDG_CONFIG_HOME` is configured but its Macropad profile directory does not
|
|
127
|
+
exist, an existing legacy `~/.config/macropad/profiles/` directory remains active. Create or migrate
|
|
128
|
+
profiles into the XDG directory to switch; when both directories exist, the XDG directory wins.
|
|
129
|
+
Macropad never moves profile files automatically.
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
device: My Macro Keyboard
|
|
133
|
+
version: '1'
|
|
134
|
+
bindings:
|
|
135
|
+
KEY_A: notify-send Macropad 'A released'
|
|
136
|
+
KEY_B:
|
|
137
|
+
down: playerctl play-pause
|
|
138
|
+
up:
|
|
139
|
+
- notify-send Macropad 'B released'
|
|
140
|
+
- logger 'Macropad B released'
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Unknown top-level fields, key names, event names, layer fields, and duplicate YAML keys are errors.
|
|
144
|
+
`device` must be a non-empty string. `version` may be the string `'1'` or integer `1`; omitted
|
|
145
|
+
versions default to 1. A complete merged device configuration must contain at least one base action.
|
|
146
|
+
|
|
147
|
+
Use any key name exported by Linux evdev, such as `KEY_A`, `KEY_UP`, or `KEY_PLAYPAUSE`. A command
|
|
148
|
+
string is shorthand for an `up` action. An event can run one command string or a non-empty list of
|
|
149
|
+
commands, which are submitted in the listed order as independent detached processes.
|
|
150
|
+
|
|
151
|
+
### Events
|
|
152
|
+
|
|
153
|
+
| Event | Behavior |
|
|
154
|
+
|--------------|--------------------------------------------------------------------------------------------------|
|
|
155
|
+
| `down` | Runs on key press. A binding containing only `down` also repeats on kernel key-repeat events. |
|
|
156
|
+
| `up` | Runs when the key is released. |
|
|
157
|
+
| `hold` | Resolves when evdev reports that the key was held; this depends on the keyboard repeat behavior. |
|
|
158
|
+
| `double_tap` | Runs after two press/release pairs occur within the multi-tap resolution window. |
|
|
159
|
+
| `triple_tap` | Runs after three press/release pairs occur within the multi-tap resolution window. |
|
|
160
|
+
|
|
161
|
+
Bindings with multiple event choices or requiring hold or multi-tap resolution wait for a 200 ms
|
|
162
|
+
quiet period. Simple bindings containing one immediate event run without that delay.
|
|
163
|
+
|
|
164
|
+
```yaml
|
|
165
|
+
device: My Macro Keyboard
|
|
166
|
+
version: '1'
|
|
167
|
+
bindings:
|
|
168
|
+
KEY_C:
|
|
169
|
+
up: notify-send Macropad 'Single tap'
|
|
170
|
+
double_tap: notify-send Macropad 'Double tap'
|
|
171
|
+
triple_tap: notify-send Macropad 'Triple tap'
|
|
172
|
+
KEY_D:
|
|
173
|
+
up: notify-send Macropad 'Released normally'
|
|
174
|
+
hold: notify-send Macropad 'Held and released'
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Layers
|
|
178
|
+
|
|
179
|
+
Layer commands begin with `^` and are handled by Macropad instead of the shell:
|
|
180
|
+
|
|
181
|
+
| Command | Behavior |
|
|
182
|
+
|----------------------|----------------------------------------------------------------------|
|
|
183
|
+
| `^layer <name>` | Activates a persistent layer. |
|
|
184
|
+
| `^layer <name> once` | Activates a layer for the next key, with a five-second idle timeout. |
|
|
185
|
+
| `^default_layer` | Deactivates the current layer. |
|
|
186
|
+
|
|
187
|
+
Layer references are checked after all fragments for a device are merged. This permits one fragment
|
|
188
|
+
to activate a layer defined in another fragment while still rejecting genuinely missing layers.
|
|
189
|
+
Active layers use only their own bindings; keys absent from the layer do not fall back to base
|
|
190
|
+
bindings.
|
|
191
|
+
|
|
192
|
+
Top-level layers collect all alternate bindings in one section:
|
|
193
|
+
|
|
194
|
+
```yaml
|
|
195
|
+
device: My Macro Keyboard
|
|
196
|
+
version: '1'
|
|
197
|
+
bindings:
|
|
198
|
+
KEY_SPACE:
|
|
199
|
+
up: ^layer navigation
|
|
200
|
+
KEY_N:
|
|
201
|
+
up: ^layer navigation once
|
|
202
|
+
layers:
|
|
203
|
+
navigation:
|
|
204
|
+
bindings:
|
|
205
|
+
KEY_H: notify-send Macropad Left
|
|
206
|
+
KEY_L: notify-send Macropad Right
|
|
207
|
+
KEY_ESC: ^default_layer
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
An inline layer defines the alternate action beside a key's base action. It produces the same layer
|
|
211
|
+
configuration as the top-level form:
|
|
212
|
+
|
|
213
|
+
```yaml
|
|
214
|
+
device: My Macro Keyboard
|
|
215
|
+
version: '1'
|
|
216
|
+
bindings:
|
|
217
|
+
KEY_SPACE:
|
|
218
|
+
up: ^layer navigation
|
|
219
|
+
KEY_H:
|
|
220
|
+
up: notify-send Macropad Base
|
|
221
|
+
layers:
|
|
222
|
+
navigation:
|
|
223
|
+
up: notify-send Macropad Left
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Layers cannot contain nested layers. Persistent layers remain active until an action runs
|
|
227
|
+
`^default_layer`. One-shot layers deactivate after the claimed key is released or the idle timeout
|
|
228
|
+
passes.
|
|
229
|
+
|
|
230
|
+
### Profile Fragments
|
|
231
|
+
|
|
232
|
+
Multiple files with the same exact `device` name are merged before a worker starts. This allows base
|
|
233
|
+
bindings and layers to be organized into separate files:
|
|
234
|
+
|
|
235
|
+
```yaml
|
|
236
|
+
# media.yml
|
|
237
|
+
device: My Macro Keyboard
|
|
238
|
+
version: '1'
|
|
239
|
+
bindings:
|
|
240
|
+
KEY_PLAYPAUSE: playerctl play-pause
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
```yaml
|
|
244
|
+
# volume.yml
|
|
245
|
+
device: My Macro Keyboard
|
|
246
|
+
version: '1'
|
|
247
|
+
bindings:
|
|
248
|
+
KEY_VOLUMEUP: playerctl volume 0.05+
|
|
249
|
+
KEY_VOLUMEDOWN: playerctl volume 0.05-
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Bindings for different keys or events combine. Defining different commands for the same device,
|
|
253
|
+
layer, key, and event is a conflict and validation fails with the later file and field path.
|
|
254
|
+
|
|
255
|
+
When default profiles or `--watch` directories are used, Macropad recognizes `.yml` files that are
|
|
256
|
+
created, modified, deleted, or moved. Move events inspect both source and destination paths so
|
|
257
|
+
editors that atomically replace profiles through temporary files are supported. A burst of changes
|
|
258
|
+
is coalesced until the directory has been quiet for one second, then the complete candidate set is
|
|
259
|
+
loaded and merged once. An invalid edit is reported while the last valid workers continue running.
|
|
260
|
+
|
|
261
|
+
### Action Execution And Security
|
|
262
|
+
|
|
263
|
+
Profile actions are trusted shell code and must never be loaded from an untrusted source. Each
|
|
264
|
+
command runs with `shell=True`, starts from `/`, inherits the Macropad process environment, receives
|
|
265
|
+
no stdin, and normally has stdout and stderr discarded. Actions are detached and continue across
|
|
266
|
+
profile reloads or worker shutdown.
|
|
267
|
+
|
|
268
|
+
Each keyboard worker tracks at most eight concurrent actions. Additional actions are dropped rather
|
|
269
|
+
than queued until an earlier action exits. The systemd user service includes `~/bin`, `~/.local/bin`,
|
|
270
|
+
and standard system command directories in its deterministic `PATH`. Use absolute paths or a service
|
|
271
|
+
override for commands installed in other interactive-shell or tool-manager directories.
|
|
272
|
+
|
|
273
|
+
### Runtime And Action Debugging
|
|
274
|
+
|
|
275
|
+
Global logging options precede the subcommand and work with both `macropad` and
|
|
276
|
+
`python -m macropad`:
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
macropad --verbose listen
|
|
280
|
+
python -m macropad --debug listen
|
|
281
|
+
macropad --action-debug listen
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Normal mode shows warnings and errors, including failed action starts, nonzero exits, worker
|
|
285
|
+
failures, and actions dropped at the concurrency limit. `--verbose` adds lifecycle summaries,
|
|
286
|
+
resolved action submissions, process starts, successful exits, layer transitions, and profile
|
|
287
|
+
reloads. `--debug` also shows unbound input, event resolution, active binding selection, and the
|
|
288
|
+
action execution environment.
|
|
289
|
+
|
|
290
|
+
Action diagnostics identify the resolved device, `KEY_*` name, event, base or named layer, command,
|
|
291
|
+
process ID, exit status, and concurrency count where applicable. Debug environment output includes
|
|
292
|
+
the `/` working directory, action `PATH`, display names, whether a DBus session address is set, and
|
|
293
|
+
whether output is discarded or inherited. It intentionally does not dump the complete environment
|
|
294
|
+
or the DBus address.
|
|
295
|
+
|
|
296
|
+
`--action-debug` implies debug logging and changes only action stdout and stderr: they inherit the
|
|
297
|
+
Macropad process streams instead of `/dev/null`. In a foreground listener they appear in that
|
|
298
|
+
terminal; when configured on the systemd service command they go to the journal. This output can
|
|
299
|
+
contain credentials or other sensitive application data, so enable it only while diagnosing a
|
|
300
|
+
trusted action. Stdin remains `/dev/null`, actions remain detached, and the eight-action limit is
|
|
301
|
+
unchanged.
|
|
302
|
+
|
|
303
|
+
The generated service uses `--verbose` so lifecycle and action summaries remain available through
|
|
304
|
+
`macropad service logs`. To capture action output in the journal, add `--action-debug` before
|
|
305
|
+
`listen` in the service's effective `ExecStart`, reload the unit, and restart the service. Remove it
|
|
306
|
+
after debugging.
|
|
307
|
+
|
|
308
|
+
### Validation
|
|
309
|
+
|
|
310
|
+
`macropad validate` uses the same loading, strict schema validation, fragment grouping, merge
|
|
311
|
+
conflict detection, and merged semantic checks as startup. It does not initialize notifications,
|
|
312
|
+
start workers, execute actions, or open input devices.
|
|
313
|
+
|
|
314
|
+
With no arguments, it validates the default profile directory without creating it. Explicit files
|
|
315
|
+
and directories can be combined:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
macropad validate base.yml --directory ./profile-fragments
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
A valid complete set prints a blank-separated `PASS` section for each file, followed by the
|
|
322
|
+
profile-file and device counts, and exits with status 0. Missing or invalid files get their own
|
|
323
|
+
`FAIL` sections with multiline source and field-path diagnostics. Files that pass standalone schema
|
|
324
|
+
validation show `PARSED` instead of `PASS` when merged validation cannot complete. Unresolved layers
|
|
325
|
+
and conflicts are attributed to the relevant file; device-wide errors use a `Profile set` section.
|
|
326
|
+
|
|
327
|
+
## Diagnostics
|
|
328
|
+
|
|
329
|
+
Run `macropad doctor` before starting the service to check input-device enumeration, open and
|
|
330
|
+
exclusive-grab access, the default profile directory, optional desktop notifications, executable and
|
|
331
|
+
service paths, current and service action `PATH` values, and graphical-session variables. Each
|
|
332
|
+
blocking `FAIL` includes remediation.
|
|
333
|
+
Expected grabs held by an active Macropad service are reported as nonblocking `WARN` results;
|
|
334
|
+
optional notification, service, and session-environment gaps are `INFO` results.
|
|
335
|
+
|
|
336
|
+
The input check briefly grabs and immediately releases each readable event device, closing every
|
|
337
|
+
handle even when a check fails. When the service is active, stop it and rerun doctor only when you
|
|
338
|
+
need to distinguish Macropad's expected grabs from another input grabber:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
macropad service stop
|
|
342
|
+
macropad doctor
|
|
343
|
+
macropad service start
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Input Permissions
|
|
347
|
+
|
|
348
|
+
On Debian/Ubuntu, add the current user to the `input` group and then log out and back in:
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
sudo usermod --append --groups input "$USER"
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
On Fedora, use the same group assignment and start a new login session:
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
sudo usermod --append --groups input "$USER"
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Some desktop environments provide device access through per-session ACLs, so group membership is
|
|
361
|
+
not required when `macropad doctor` already reports input access as `PASS`. Membership in the
|
|
362
|
+
`input` group grants access to all input events and can expose every keystroke, including passwords.
|
|
363
|
+
Prefer a device-specific udev rule when broad input access is not acceptable.
|
|
364
|
+
|
|
365
|
+
## Device Monitoring
|
|
366
|
+
|
|
367
|
+
Run `macropad monitor` without arguments to list every readable input device. Devices sharing an
|
|
368
|
+
exact evdev name are grouped together and every matching `/dev/input/event*` path is shown; paths
|
|
369
|
+
that cannot be opened include their permission or device error.
|
|
370
|
+
|
|
371
|
+
Pass an exact listed name to stream key activity:
|
|
372
|
+
|
|
373
|
+
```text
|
|
374
|
+
CONNECTED /dev/input/event12
|
|
375
|
+
down KEY_A /dev/input/event12
|
|
376
|
+
repeat KEY_A /dev/input/event12
|
|
377
|
+
up KEY_A /dev/input/event12
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Monitoring never exclusively grabs a device, so normal keyboard input continues. It opens every
|
|
381
|
+
current path with the selected name, reports disconnects, reacquires matching paths after reconnect,
|
|
382
|
+
and exits cleanly with Ctrl+C or SIGTERM. An active Macropad worker already holds its configured
|
|
383
|
+
device exclusively; if monitor connects but shows no events, run `macropad service stop` before
|
|
384
|
+
monitoring and start the service again afterward.
|
|
385
|
+
|
|
386
|
+
## Guided Initialization
|
|
387
|
+
|
|
388
|
+
Run `macropad init` to create one working release binding without manually discovering evdev names
|
|
389
|
+
or writing YAML. The command first runs the blocking input-device checks from `macropad doctor`, then
|
|
390
|
+
asks you to disconnect the target keyboard. Detection starts only after you confirm that it is
|
|
391
|
+
disconnected: reconnect it and press the key you want to configure. By default, each device or key
|
|
392
|
+
capture times out after 60 seconds; use `--timeout SECONDS` to choose another positive timeout.
|
|
393
|
+
|
|
394
|
+
The command asks for a trusted shell command and writes a new fragment under the resolved default
|
|
395
|
+
profile directory. Generated macros run when the captured key is released. The directory follows the
|
|
396
|
+
same XDG and legacy fallback rules as `listen` and `validate`.
|
|
397
|
+
|
|
398
|
+
If the detected device already has profiles, `init` lists every existing fragment and asks whether to
|
|
399
|
+
add a new one. It never edits those files. If the captured key already has an `up` action, release the
|
|
400
|
+
key and capture another one or cancel. Other events on that key can safely merge with the generated
|
|
401
|
+
release binding.
|
|
402
|
+
|
|
403
|
+
Filenames are derived from the device and key, for example
|
|
404
|
+
`macro_keyboard_key_a.yml`. Existing filenames are preserved and a numeric suffix is selected. The
|
|
405
|
+
new fragment is conflict-checked against the complete existing profile set before creation, opened
|
|
406
|
+
exclusively, and validated with the normal complete on-disk validation workflow before success is
|
|
407
|
+
reported. Cancellation, timeout, write failure, or validation failure removes the new file without
|
|
408
|
+
touching existing fragments.
|
|
409
|
+
|
|
410
|
+
An active Macropad service may already own a configured keyboard and prevent non-grabbing key
|
|
411
|
+
capture. If initialization times out for an existing device, stop the service and retry:
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
macropad service stop
|
|
415
|
+
macropad init
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
On success, `init` reports the exact path and refreshes the systemd service state. Active state alone
|
|
419
|
+
cannot prove which arguments a customized service uses, so automatic loading is confirmed only as a
|
|
420
|
+
condition of the standard `listen --watch` command and default profile directory. If the service is
|
|
421
|
+
inactive, start in the foreground with `macropad listen` or use the service command shown by `init`.
|
|
422
|
+
|
|
423
|
+
## Runtime Status
|
|
424
|
+
|
|
425
|
+
`macropad status` reports whether each configured keyboard worker is actually waiting, opening event
|
|
426
|
+
paths, listening after a successful exclusive grab, backing off after failure, reporting an input
|
|
427
|
+
error, or shutting down. It includes the parent and worker PIDs, profile fragment paths, currently
|
|
428
|
+
grabbed event paths, failure reason, and retry delay where available:
|
|
429
|
+
|
|
430
|
+
```text
|
|
431
|
+
Macropad parent PID: 1234
|
|
432
|
+
|
|
433
|
+
Macro Keyboard
|
|
434
|
+
state: listening
|
|
435
|
+
pid: 1235
|
|
436
|
+
profiles: /home/user/.config/macropad/profiles/macro.yml
|
|
437
|
+
paths: /dev/input/event12
|
|
438
|
+
|
|
439
|
+
Media Pad
|
|
440
|
+
state: backing_off (retry in 4.0s)
|
|
441
|
+
profiles: /home/user/.config/macropad/profiles/media.yml
|
|
442
|
+
error: process 1236 exited
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
An invalid watched profile candidate is shown separately while the last valid workers keep running.
|
|
446
|
+
Permission and grab errors include the affected event path when known. `listening` is reported only
|
|
447
|
+
after the worker successfully grabs at least one matching path; a visible device before child startup
|
|
448
|
+
does not count as listening.
|
|
449
|
+
|
|
450
|
+
The command connects to a read-only Unix socket owned by the listening parent under
|
|
451
|
+
`$XDG_RUNTIME_DIR/macropad/`, with a user-specific directory under the system temporary directory as
|
|
452
|
+
a fallback. The directory and socket are user-only, stale sockets are removed safely, and no remote
|
|
453
|
+
control operations are exposed. If no parent is reachable, the command reports whether the systemd
|
|
454
|
+
service is active and points to the appropriate next command.
|
|
455
|
+
|
|
456
|
+
`macropad status` and `macropad service status` answer different questions: the former reports live
|
|
457
|
+
Macropad worker/device readiness, while the latter remains a direct proxy for systemd unit state and
|
|
458
|
+
logs.
|
|
459
|
+
|
|
460
|
+
## Service
|
|
461
|
+
|
|
462
|
+
Install and start the systemd user service:
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
macropad service install
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
The command writes `$XDG_CONFIG_HOME/systemd/user/macropad.service` when `XDG_CONFIG_HOME` is
|
|
469
|
+
absolute, defaulting to `~/.config/systemd/user/macropad.service`, then reloads systemd and enables
|
|
470
|
+
and starts the unit. The generated unit invokes the `macropad` executable from the active tool
|
|
471
|
+
environment and does not depend on a source checkout. Reinstalling updates a recognized generated
|
|
472
|
+
unit. Macropad refuses to replace an unrelated unit at that path unless
|
|
473
|
+
`macropad service install --force` is used.
|
|
474
|
+
|
|
475
|
+
Manage the installed unit through the CLI:
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
macropad service status
|
|
479
|
+
macropad service logs
|
|
480
|
+
macropad service restart
|
|
481
|
+
macropad service stop
|
|
482
|
+
macropad service disable
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
`service logs` follows the systemd journal until interrupted. These commands preserve the output and
|
|
486
|
+
exit status from `systemctl --user` or `journalctl --user`. Use `macropad listen` instead when running
|
|
487
|
+
Macropad directly in the foreground.
|
|
488
|
+
|
|
489
|
+
### Upgrade And Uninstall
|
|
490
|
+
|
|
491
|
+
Upgrade the tool, refresh the generated service path, and restart it:
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
uv tool upgrade poor-mans-macropad
|
|
495
|
+
macropad service install
|
|
496
|
+
macropad service restart
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
For `pipx`, replace the first command with `pipx upgrade poor-mans-macropad`.
|
|
500
|
+
|
|
501
|
+
Remove the service before uninstalling the tool:
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
macropad service uninstall
|
|
505
|
+
uv tool uninstall poor-mans-macropad
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
`service uninstall` stops and disables the unit, removes it only when its generated marker is
|
|
509
|
+
present, and reloads systemd. It does not remove profiles. For a `pipx` installation, use
|
|
510
|
+
`pipx uninstall poor-mans-macropad` as the final command.
|
|
511
|
+
|
|
512
|
+
## Development
|
|
513
|
+
|
|
514
|
+
Install the native dependencies listed above, then create the project environment. Development uses
|
|
515
|
+
the same service renderer and lifecycle as released installations:
|
|
516
|
+
|
|
517
|
+
```bash
|
|
518
|
+
make
|
|
519
|
+
make install-editable
|
|
520
|
+
uv run macropad service install
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
```bash
|
|
524
|
+
make test
|
|
525
|
+
make test-init
|
|
526
|
+
make test-wheel
|
|
527
|
+
make test-service
|
|
528
|
+
make test-systemd
|
|
529
|
+
make lint
|
|
530
|
+
make build
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
Run `make format` to apply the Ruff lint and formatting policy.
|
|
534
|
+
|
|
535
|
+
CI runs the unit suite on Python 3.10 through 3.14, verifies linting, formatting, the lockfile, wheel
|
|
536
|
+
installation, packaged assets, service lifecycle, systemd unit, and distribution build. See
|
|
537
|
+
[`RELEASING.md`](RELEASING.md) for the Trusted Publishing release process.
|
|
538
|
+
|
|
539
|
+
## License
|
|
540
|
+
|
|
541
|
+
Macropad is available under the [MIT License](LICENSE).
|