Plugins API¶
Every plugin is a plain Python module that follows a small contract rather than
subclassing a base class. A module is loaded if it exposes a NAME string and a
handle(cmd, core) function; the optional setup(core) hook runs once at
startup, and COMMANDS/DESCRIPTION feed the help screen.
classDiagram
class PluginContract {
<<protocol>>
+str NAME
+str DESCRIPTION
+list COMMANDS
+setup(core)
+handle(cmd, core)
}
class base
class sleep
class system
class media
class files
class apps
class browser
class dictation
class mousegrid
class headtrack
PluginContract <|.. base
PluginContract <|.. sleep
PluginContract <|.. system
PluginContract <|.. media
PluginContract <|.. files
PluginContract <|.. apps
PluginContract <|.. browser
PluginContract <|.. dictation
PluginContract <|.. mousegrid
PluginContract <|.. headtrack
note for base "zz_base.py — loads last; help and exit fallback"
note for mousegrid "00_mousegrid.py — numeric prefix loads it early"
note for headtrack "00_eyetrack.py — numeric prefix loads it early"
handle returns True when it consumed the command, False to signal the
daemon to exit, or None to pass the command to the next plugin. Load order is
alphabetical, so numeric prefixes (00_) load a plugin early and the zz_
prefix loads the base plugin last as the catch-all for help and exit.
base (zz_base)¶
plugins.zz_base
¶
Base Plugin - Help and Exit.
setup
¶
handle
¶
Handle the help and exit commands; return None to pass others through.
Returns False to signal the daemon to exit, True if help was shown, or None when the command is for another plugin.
Source code in src/plugins/zz_base.py
show_help
¶
List every plugin's commands on the terminal.
Printed rather than logged: it is the direct reply to an explicit "help" request (the spoken reply tells the user to read the terminal), so it must appear regardless of the configured log verbosity.
Source code in src/plugins/zz_base.py
sleep¶
plugins.sleep
¶
Sleep Plugin - Deactivate the assistant by voice.
"Go to sleep" (or "stop listening") releases the microphone and stops wake-word detection until the user reactivates EasySpeak from the GNOME tray indicator or the Quick Settings toggle — whichever the extension is showing, the one way back since voice control is off until reactivated.
handle
¶
Deactivate the assistant on a sleep phrase; return None otherwise.
Source code in src/plugins/sleep.py
system¶
plugins.system
¶
System Plugin - Volume, brightness, do not disturb.
setup
¶
volume_up
¶
volume_down
¶
volume_mute
¶
volume_max
¶
volume_min
¶
brightness_up
¶
brightness_down
¶
dnd_on
¶
dnd_off
¶
Disable do-not-disturb by showing notification banners again.
handle
¶
Route a volume/brightness/DND command; return None if none matched.
Source code in src/plugins/system.py
media¶
plugins.media
¶
Media Plugin - Playback controls via MPRIS.
setup
¶
get_media_players
¶
Return the bus names of all running MPRIS media players.
Source code in src/plugins/media.py
media_control
¶
Send an MPRIS action (play/pause/next/previous) to every running player.
Returns False if no player is running or the action is unknown.
Source code in src/plugins/media.py
handle
¶
Map a playback command to an MPRIS action; return None if not media.
The reply now follows the action rather than preceding it: this used to announce "Playing." and return handled even when no player was running, so a command that did nothing at all sounded like it had worked.
Source code in src/plugins/media.py
files¶
plugins.files
¶
Files Plugin - Open folders in file manager.
setup
¶
open_folder
¶
Open a folder in the user's default file manager; False if unavailable.
Delegates to xdg-open so whichever file manager the desktop is configured for is honoured, rather than hardcoding one. Launched with a clean environment (see core.host_run) so it doesn't inherit EasySpeak's library paths.
Source code in src/plugins/files.py
handle
¶
Open a named folder, or the file manager itself; None if neither matched.
Source code in src/plugins/files.py
apps¶
plugins.apps
¶
Apps Plugin - Launch and close applications.
setup
¶
find_app
¶
Find app - returns (type, id).
Source code in src/plugins/apps.py
launch_app
¶
Launch the named app (flatpak or local binary); False if not found.
Source code in src/plugins/apps.py
close_app
¶
Close the named app (flatpak kill or pkill); False if not found.
Source code in src/plugins/apps.py
handle
¶
Open or close an app named in the command; return None if none matched.
Source code in src/plugins/apps.py
browser¶
plugins.browser
¶
Browser Plugin - Qutebrowser voice control via IPC.
adblock_method
¶
Return the strongest ad-blocking method qutebrowser can actually run.
Ad overlays and newsletter interstitials are numbered like anything else, so
they take hint numbers away from the page underneath and a spoken hint lands
on a popup instead of the link the user meant. "both" adds Brave's ABP engine,
which is what catches those overlays -- but it needs the adblock module, and
without it qutebrowser complains on every single page load, which is worse
than the ads. Host blocking is built in and needs nothing.
The module has to be importable by the interpreter that runs qutebrowser,
which is often not the python3 on PATH: a virtualenv, a distro package, a
Flatpak or a Nix build each ship their own. So this asks qutebrowser itself
rather than probing a stray interpreter, which answered correctly only when
the two happened to coincide. --version lists each optional module as
adblock: <version> when present and adblock: no when not, so a leading
digit means "both"; installing the module later is still picked up on the
next start. That call imports Qt and so is slow rather than instant, so the
15-second timeout is a ceiling for a wedged process, not an expected wait --
past it, host blocking (which always works) is assumed.
Source code in src/plugins/browser.py
required_qutebrowser_lines
¶
The config lines EasySpeak needs, suited to what's installed.
set_config_line
¶
Add or remove one line in qutebrowser's config.py, keyed on its setting.
Returns None when the config can't be written, so the caller can say why.
Source code in src/plugins/browser.py
ensure_qutebrowser_config
¶
Bring qutebrowser's config.py in line with what EasySpeak needs.
Preserves everything else the user has written. Tolerates read-only configs (e.g. Nix Home-Manager symlinks into /nix/store): on a write failure we emit a polite note telling the user which lines to add themselves, rather than crashing startup.
Source code in src/plugins/browser.py
setup
¶
Store the core reference and write the required qutebrowser config.
qb
¶
qb_open
¶
parse_hint_numbers
¶
Extract hint numbers from spoken words.
looks_like_hint
¶
Check if command looks like a hint number (short, mostly digits/number words).
Source code in src/plugins/browser.py
parse_hint_number
¶
Parse spoken numbers into a hint string ('zero two' -> '02').
Source code in src/plugins/browser.py
parse_tab_number
¶
The tab number a command names, or None if it doesn't name one.
Source code in src/plugins/browser.py
parse_spoken_url
¶
Convert spoken URL to actual URL.
'claude dot ai' -> 'https://claude.ai'.
Source code in src/plugins/browser.py
show_hints
¶
scroll_page
¶
listen_for_hint
¶
Listen for a hint number after showing hints.
retries_left bounds how many times a repeated "numbers" can keep the
listener open, so a run of mishearings can't recurse without end.
Source code in src/plugins/browser.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
handle
¶
Enter browser mode on a browser command; return None otherwise.
A matching command launches qutebrowser (if needed) and runs the continuous browser-mode loop; reserved global commands (sleep/quit) are passed through. Outside the explicit "open browser", navigation commands are only acted on when a browser is already running, so ambiguous words can't open one.
Source code in src/plugins/browser.py
browser_mode
¶
Handle browser commands until the user leaves or the mode ends.
Core owns the listening loop (see
listen_modal) so the tray keeps working while
browser mode holds the microphone, and an
unattended session ends on its own instead of leaving the wake word unreachable.
Source code in src/plugins/browser.py
strip_filler
¶
Remove a leading filler word Whisper added to the front of a command.
handle_browser_command
¶
Execute a single in-browser command; None if it isn't recognised.
Source code in src/plugins/browser.py
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | |
dictation¶
plugins.dictation
¶
Dictation Plugin - Voice to text via AT-SPI.
ensure_gnome_accessibility
¶
Enable GNOME's toolkit-accessibility for the AT-SPI bridge.
Silently skipped if gsettings isn't on PATH or the schema isn't installed (i.e. user isn't on GNOME). Warns if it's present but the flip fails. Tells the user to re-login when newly enabled.
Source code in src/plugins/dictation.py
setup
¶
Store the core reference and enable the GNOME accessibility bridge.
Source code in src/plugins/dictation.py
is_exit_phrase
¶
focused_wm_class
¶
Return the focused window's WM class, or None if it can't be read.
Asks the bundled GNOME extension, the same way the mouse grid asks it for the screen size. Only used to pick the paste chord, so any failure simply means the default one.
Source code in src/plugins/dictation.py
paste_chord
¶
Return the evdev keycodes for the paste chord to send.
wm_class is the focused window if the caller already looked it up; reading it
again costs a gdbus round trip on the path between speaking and seeing text.
EASYSPEAK_PASTE_KEYS overrides it outright (e.g. shift+insert); otherwise
terminals get Ctrl+Shift+V and everything else Ctrl+V. An unknown key name in
the override is reported and the default used, rather than silently sending a
chord that does nothing.
Source code in src/plugins/dictation.py
clipboard_tools
¶
Return the (copy, paste) commands, or (None, None) if wl-clipboard is absent.
EasySpeak targets Wayland, so wl-clipboard is the only supported tool. Without it there is no way to put text on the clipboard.
Source code in src/plugins/dictation.py
read_clipboard
¶
Return the current clipboard text, or None if there isn't any.
Read as bytes and decoded here rather than by subprocess, because the
clipboard often isn't text at all -- a copied image arrives as PNG bytes, and
decoding those as UTF-8 raised straight out of the middle of an insertion and
killed dictation mid-sentence.
Non-text content simply isn't preserved: the dictated text still gets pasted, but whatever was on the clipboard is gone afterwards. Restoring arbitrary binary would mean tracking MIME types through both tools, which is a lot of machinery for something a user rarely notices.
Source code in src/plugins/dictation.py
write_clipboard
¶
Put text on the clipboard; False if that failed.
Output goes to /dev/null rather than a pipe. wl-copy forks a daemon to hold
the selection for as long as it owns it, and that daemon inherits whatever
pipes we hand the parent -- so capturing output makes subprocess.run wait on
a process that never exits (CPython bpo-37424). Every copy timed out, and
dictation reported that it couldn't reach the clipboard.
Source code in src/plugins/dictation.py
leave_browser_insert_mode
¶
Hand qutebrowser back in normal mode once dictation is over.
Insert mode is entered so a paste reaches the page, but leaving the browser in it means every later keystroke is treated as text: hinting and scrolling both misbehave, which looked like dictation breaking the browser on its way out.
Source code in src/plugins/dictation.py
has_focused_text_field
¶
Whether anything is focused that could receive text.
Chromium-based apps accept an AT-SPI insertion and quietly discard it, which is why text goes in by clipboard and paste instead. They do still report which element holds focus, though, so the helper is run with an empty string purely as a question: it finds the insertion point, writes nothing, and says whether there was one.
Any failure answers yes. A probe that can't run is no reason to refuse to paste -- the old behaviour, blind but willing, is the better fallback.
Source code in src/plugins/dictation.py
insert_text
¶
Insert text into the focused application by pasting it.
The clipboard is put back afterwards, so dictating doesn't quietly cost the user whatever they had copied. Falls back to AT-SPI when no clipboard tool is installed, which is the only case where the old path was ever the better one.
Source code in src/plugins/dictation.py
atspi_python
¶
Path to an interpreter that can actually run the AT-SPI helper, or None.
The helper needs PyGObject and the AT-SPI typelib, which the app's own venv
usually lacks. EASYSPEAK_ATSPI_PYTHON lets the packaging point straight at an
interpreter that has them (the Nix flake sets it). Otherwise each candidate is
probed with the helper's own import chain and the first that works is kept.
Falling back to a bare python3 used to be enough, but only until the daemon
was run from an activated virtualenv: python3 then resolves to the venv's
interpreter, which has no PyGObject, and dictation transcribed perfectly and
inserted nothing.
Source code in src/plugins/dictation.py
insert_via_atspi
¶
Insert text via AT-SPI.
Returns one of INSERTED, NO_FOCUS or BACKEND_ERROR so the caller can give feedback that matches the real cause instead of always blaming focus.
Source code in src/plugins/dictation.py
format_text
¶
Convert spoken punctuation to actual punctuation.
Source code in src/plugins/dictation.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | |
run_push_to_talk
¶
Dictate while the activation keys are held (the silent-activation path).
Mirrors the voice notes loop but is gated on should_continue — a predicate that
is True while the keys remain held — instead of a spoken "stop notes": each
utterance captured from core is formatted and inserted until the keys are
released. The capture waits re-check should_continue so releasing stops dictation
promptly.
Source code in src/plugins/dictation.py
handle
¶
Enter dictation mode on a whole-word "note"/"notes"; return None otherwise.
Matching whole words (not substrings) keeps unrelated words like "notebook" or
"noted" from triggering it. While in dictation mode core drives the listening
(see listen_modal), transcribing speech and
inserting it into the focused field until "stop notes" is heard — or until the
mode ends on its own, so an open microphone can't be left dictating unattended.
Source code in src/plugins/dictation.py
mousegrid (00_mousegrid)¶
plugins.00_mousegrid
¶
Mouse Grid Plugin - Voice-controlled mouse via GNOME Shell D-Bus extension.
Features: - Chained numbers: "3 7 5" zooms three times in one utterance - Repetition: "nudge up 5", "scroll down 3" - Drag support: "mark" to start, "drag" to end
setup
¶
host_run
¶
Run a command and capture its output (the plugin's own subprocess seam).
A missing executable returns a failed result (returncode 1) rather than
raising, so callers treat an absent gdbus—e.g. on a headless host such as
WSL with no GNOME session—as a plain D-Bus failure. Without this the atexit
cleanup would raise FileNotFoundError on exit.
Source code in src/plugins/00_mousegrid.py
dbus_call
¶
Call a method on the grid extension over D-Bus; True on success.
Source code in src/plugins/00_mousegrid.py
get_screen_size
¶
Get screen size from GNOME Shell extension (accurate for Wayland).
Source code in src/plugins/00_mousegrid.py
cleanup
¶
parse_number_sequence
¶
Extract ALL numbers from text as a sequence.
'3 7 5' -> [3, 7, 5].
Source code in src/plugins/00_mousegrid.py
parse_count
¶
Extract a repeat count (for nudge/scroll).
Returns single number or 1.
Source code in src/plugins/00_mousegrid.py
parse_direction
¶
Return the direction (up/down/left/right) named in text, or None.
get_center
¶
Return the (x, y) center of the current grid cell, or None if no grid.
show_grid
¶
Show the full-screen grid overlay (no-op if it is already active).
Source code in src/plugins/00_mousegrid.py
close_grid
¶
update_grid
¶
Zoom to a single zone.
Returns True if successful.
Source code in src/plugins/00_mousegrid.py
process_zones
¶
do_click
¶
Click at the current cell center and close the grid; False if no grid.
Source code in src/plugins/00_mousegrid.py
do_scroll
¶
Scroll count steps at the current cell center; False if no grid.
Source code in src/plugins/00_mousegrid.py
nudge_grid
¶
Shift the current cell count steps in a direction; False if no grid.
Source code in src/plugins/00_mousegrid.py
start_drag
¶
Press at the current cell center and reset the grid to full screen.
Leaves a drag in progress so a later end_drag
releases at the new target. False if no grid is active.
Source code in src/plugins/00_mousegrid.py
end_drag
¶
Release a drag and close the grid.
Releases a drag started by start_drag.
False if no drag is in progress or no grid is active.
Source code in src/plugins/00_mousegrid.py
handle
¶
Show or reopen the grid on a trigger word, then enter grid mode.
Returns None for commands that don't open the grid.
Source code in src/plugins/00_mousegrid.py
listen_for_grid_commands
¶
Handle grid commands until the grid closes or the mode ends.
Core owns the listening loop (see
listen_modal) so the tray stays responsive
while the grid holds the microphone, and an
unattended grid times out instead of trapping the session. Any drag still in
progress is released on the way out, so a timeout can't leave the mouse button
held down.
Source code in src/plugins/00_mousegrid.py
headtrack (00_eyetrack)¶
plugins.00_eyetrack
¶
Head Tracking Plugin - Cursor control via SixDRepNet.
Uses a 6D rotation representation for smooth head pose estimation.
OneEuroFilter
¶
One-Euro filter for smoothing noisy signals.
Adaptive: smooth when the signal is still, responsive when it moves.
Initialise the filter's cutoff/responsiveness parameters.
Source code in src/plugins/00_eyetrack.py
__call__
¶
Filter the next sample x and return the smoothed value.
Source code in src/plugins/00_eyetrack.py
setup
¶
host_run
¶
dbus_call
¶
Call GNOME Shell extension for cursor movement.
Source code in src/plugins/00_eyetrack.py
get_screen_size
¶
Get screen size from GNOME Shell extension.
Source code in src/plugins/00_eyetrack.py
run_tracking
¶
Main tracking loop.
Source code in src/plugins/00_eyetrack.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
start_tracking
¶
Start the head-tracking thread; returns (started, message).
Source code in src/plugins/00_eyetrack.py
stop_tracking
¶
Signal the tracking thread to stop; returns (stopped, message).
recalibrate
¶
Reset calibration - will auto-calibrate on next frames.
Source code in src/plugins/00_eyetrack.py
handle
¶
Start/stop tracking or run a tracking command; None if not head-tracking.
Source code in src/plugins/00_eyetrack.py
listen_for_tracking_commands
¶
Handle tracking commands until tracking stops or the mode ends.
Core owns the listening loop (see
listen_modal) so the tray keeps working while
tracking holds the microphone. The mode also ends
as soon as the tracking thread is gone — a webcam that failed to open used to
leave the user in a mode with nothing driving the cursor.
Source code in src/plugins/00_eyetrack.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |