Without a background daemon, everyDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Evilchuck666/WinJitsu/llms.txt
Use this file to discover all available pages before exploring further.
winjitsu N (or any other action) would cold-start a new Python process, query the display, animate the window, and exit — adding perceptible latency on every hotkey press. The daemon eliminates that overhead by staying warm between presses. It also solves the key-repeat problem: when a held hotkey fires ten times per second, the daemon collapses the burst into a single animation rather than launching ten overlapping ones.
Starting the daemon
Runwinjitsu --daemon once, typically at login. The parent process forks a child, prints its PID, then exits immediately so your terminal or autostart script is not blocked. The child calls os.setsid() to become its own session leader and detaches from the controlling terminal, then redirects stdin, stdout, and stderr to /dev/null.
Reloading the daemon
winjitsu --reload-daemon performs a graceful rolling restart:
Poll for exit
It polls with
os.kill(pid, 0) in 0.1-second intervals for up to 5 seconds, waiting for the process to disappear.--reload-daemon, the command exits with an error:
Runtime files
The daemon creates two files under a versioned runtime directory:| File | Default path |
|---|---|
| Unix socket | $XDG_RUNTIME_DIR/winjitsu/winjitsu.sock |
| PID file | $XDG_RUNTIME_DIR/winjitsu/winjitsu.pid |
$XDG_RUNTIME_DIR defaults to /run/user/<uid> when the environment variable is not set, so on most systems the socket lives at /run/user/1000/winjitsu/winjitsu.sock. The directory is created with parents=True, exist_ok=True on daemon startup, and both files are removed when the daemon exits cleanly.
The socket is created with mode 0o600, so only the owning user can connect to it.
On startup the daemon also calls clear_cache(), which deletes all rows from the windows table in the SQLite state database. This ensures that stale window positions from a previous session do not affect the first U (restore) call after a reboot or re-login.
Debounce logic
The daemon’s--delay-ms option (default 250 ms, config key [daemon] delay_ms) controls the debounce window. When the daemon receives an action over the socket it does not execute immediately. Instead it:
- Cancels any pending timer from a previous action in the burst.
- Immediately resolves the superseded action with
OKso the old client can unblock. - Schedules the new action to fire after
delay_msmilliseconds.
How actions are sent to the daemon
Everywinjitsu <ACTION> invocation (e.g., winjitsu N) is a thin client that:
- Checks whether
$XDG_RUNTIME_DIR/winjitsu/winjitsu.sockexists. - Opens a
AF_UNIX / SOCK_STREAMconnection to the socket. - Sends
ACTION\n(e.g.,N\n). - Reads one line back from the daemon and exits.
| Response | Meaning |
|---|---|
OK | Action completed successfully. |
WARN: <message> | Action ran but produced a warning (e.g., no cached state to restore). Printed to stderr. |
ERROR: <message> | Action failed. Printed to stderr; client exits 1. |
Error handling
If the socket file does not exist at the timewinjitsu <ACTION> is called, the client prints the following message to stderr and exits with code 1: