fix(capture): self-re-exec detached to survive eww 200ms timeout#92
Merged
Merged
Conversation
Previous attempt wrapped the onclick in "(cmd </dev/null >/dev/null 2>&1 &)" to background within the eww-spawned sh, but that syntax broke the eww onclick path entirely — the script was never invoked, breaking both screenshot and recording (the debug log shows no script calls at all after that change). Move the detach logic into the script itself: when called for a capture action (selection/screen/window), re-exec via `nohup ... &` with a guard env var (_STOA_CAPTURE_DETACHED) to prevent infinite recursion. The first invocation returns almost instantly — well within eww's 200ms timeout — and the detached child runs the actual sleep + grim (or wf-recorder) without being killed. The eww onclick goes back to a plain "stoa-capture <mode> <type> <delay>" which is a syntactically trivial command the eww sh has no trouble with.
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 revisada
A tentativa anterior (
(cmd </dev/null >/dev/null 2>&1 &)inline no onclick) quebrou completamente o caminho do onclick — o log de debug não mostra nenhuma invocação do script depois daquele merge. Por isso a gravação parou de funcionar também: o/bin/sh -cdo eww não engoliu aquela sintaxe.Fix
eww.yuck: onclick volta ao mínimo —stoa-capture ${capture-mode} ${capture-type} ${capture-delay}. Sintaxe trivial que o sh do eww processa sem problema.stoa-capture.sh: dentro do caseselection|screen|window, antes de fazer qualquer trabalho real, o script se re-executa em background detachado vianohup ... &e sai imediatamente. Uma env var de guarda (_STOA_CAPTURE_DETACHED) impede recursão infinita.A primeira invocação (a que o eww spawned) retorna em ms — bem antes dos 200ms. O filho detached faz
eww close,sleep 0.5, egrim(ouwf-recorder) em paz.Test plan
git pull && eww reload~/Pictures/screenshots//tmp/stoa-capture-debug.logmostraRe-execing detached,Running in detached mode,_screenshot called,Running grim ...,File exists? yesGenerated by Claude Code