fix(eww): background capture cmd to beat 200ms onclick timeout#91
Merged
Conversation
The eww source confirms run_command has a hardcoded 200ms timeout (crates/eww/src/widgets/mod.rs) — after which it SIGKILLs the onclick child. Because /bin/sh -c "single-command" execs directly into the command without an intermediate sh, the kill lands on the stoa-capture script itself. Recording survived only because wf-recorder is forked with `&` well within the 200ms window. Screenshot died mid-sleep before _screenshot ever ran (the debug log shows no entries after the "Case selection/screen/window triggered" line). `setsid -f` failed silently (likely not on PATH for the /bin/sh eww spawns, or itself killed by the timeout before forking), so no entries appeared at all on the latest attempt. Wrap the invocation in `( ... </dev/null >/dev/null 2>&1 &)` so /bin/sh forks a subshell that immediately backgrounds stoa-capture and exits. The whole sh invocation returns in microseconds, eww's timeout never fires, and stoa-capture continues as an orphaned process — sleep 0.5 and grim now complete normally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Causa raiz (finalmente)
Olhando o source do eww (
crates/eww/src/widgets/mod.rs):O onclick tem timeout de 200ms e o eww
SIGKILLa o processo se ele passar disso. E comosh -c "single-command"fazexecdireto na command (sem manter umshintermediário), o kill atinge a própriastoa-capture.Por que gravação funcionava:
_recordchamawf-recorder ... &imediatamente após oeww close, então o background fork acontece dentro dos 200ms e o wf-recorder vira órfão (sobrevive ao kill do pai).Por que screenshot falhava: O script faz
sleep 0.5(500ms) ANTES de chamargrim. O eww mata o script aos 200ms, o_screenshotnunca executa. Bate exato com o log:Por que
setsid -fnão funcionou: Provavelmente não está no PATH do/bin/shque o eww usa, ou foi morto pelo timeout antes de conseguir forkar.Fix
Envolver o invocação em
( cmd </dev/null >/dev/null 2>&1 & ):stoa-capture, sai imediatamente/bin/shretorna em microssegundos — muito antes dos 200msstoa-capturecontinua como processo órfão, faz seusleep 0.5e roda ogrimem pazsetsid/nohupTest plan
git pull && eww reload~/Pictures/screenshots//tmp/stoa-capture-debug.logagora mostra_screenshot called,Running grim ...,File exists? yesGenerated by Claude Code