Skip to main content

Module runtime

Module runtime 

Source
Expand description

Runtime coordination between the daemon and the prefs subprocess.

Both write/read a PID file at the platform’s runtime location ($XDG_RUNTIME_DIR/hyprcorrect.pid on Linux, $TMPDIR/... on macOS) so the prefs window can target SIGHUP at the daemon specifically — pkill -x hyprcorrect would catch both processes since they share a binary name.

Structs§

ReviewRequest
A pending review request — what the user typed, what the smart provider suggested, and where to emit the result.
WordSuggestions
Ranked alternative spellings for one corrected word, for the review popup’s per-field suggestion dropdown. options is best-first and the first entry is normally the applied correction; the popup drops whatever matches the field’s current text and shows the rest.

Enums§

PidError
An error reading or writing the daemon PID file.

Functions§

action_path
Path to the trigger-action file. The hyprctl bind writes “word”, “sentence”, or “review” here before signaling the daemon; the daemon reads it on SIGUSR1 to know which action fired. The review subprocess also writes “review-apply” / “review-cancel” here when it closes, so the daemon knows what to do with the pending request file.
chord_socket_path
Path to the chord-capture Unix socket. The prefs window connects here and writes capture\n to ask the daemon to deliver the next non-modifier key press (with full modifier mask, including Super) as a chord string. The socket exists because egui-winit on Linux discards Super from Modifiers, so the prefs UI cannot record SUPER-containing chords on its own.
clear_pid
Remove the daemon PID file (idempotent — missing file is OK). The action file is removed alongside it since the two have the same lifecycle: both are owned by the running daemon.
clear_review
Remove the review-request file (idempotent).
pid_path
Path to the daemon PID file. Falls back to the OS temp dir when $XDG_RUNTIME_DIR is unset (macOS, restricted environments).
read_action
Read the trigger-action file, returning the trimmed contents. An empty string is returned if the file is missing or unreadable — callers treat that as “default action” (fix-last-word).
read_daemon_pid
Read the daemon’s PID from the file. Returns Ok(None) if no file exists (no daemon running).
read_review_request
Read the pending review request, or None if no file exists.
review_path
Path to the review-request file. The daemon writes the original sentence + the proposed correction + trailing whitespace + the originating window’s address here when the review chord fires; the review subprocess reads it to populate the popup, then updates the same path with its decision on exit so the daemon’s apply handler can finish the job.
write_review_request
Write a fresh review request to disk. Overwrites any pending one.
write_self_pid
Write the current process’s PID to the daemon PID file.