Skip to content

fix(eww): use absolute path for stoa-capture so eww's /bin/sh finds it#94

Merged
VictorGSchneider merged 1 commit into
mainfrom
claude/fix-screenshot-widget-Wiz6D
May 12, 2026
Merged

fix(eww): use absolute path for stoa-capture so eww's /bin/sh finds it#94
VictorGSchneider merged 1 commit into
mainfrom
claude/fix-screenshot-widget-Wiz6D

Conversation

@VictorGSchneider
Copy link
Copy Markdown
Owner

@VictorGSchneider VictorGSchneider commented May 12, 2026

Causa raiz (finalmente)

O log do usuário mostra um detalhe que estava me enganando: as entries screen screenshot 0/1/2 que apareceram após o teste eram todas do teste manual no terminal que pedi pra ele rodar, não do widget. Pelo widget, nada continua disparando.

A diferença entre o terminal funcionando e o widget falhando é o PATH:

  • Terminal: zsh interativo carrega .zshrc que provavelmente adiciona ~/.local/bin ao PATH.
  • eww onclick: o eww spawna /bin/sh -c "stoa-capture ...". Esse sh herda o ambiente do Hyprland (que herdou de greetd/login), que não inclui ~/.local/bin — esse path normalmente é setado em rc files de shells interativos, não no ambiente do login.

Por isso o original com hardcoded /home/zeno/.local/bin/stoa-capture funcionava: caminho absoluto, achava sempre. Quando troquei pra stoa-capture no PR #87, todo o widget passou a falhar silenciosamente (clique → sh tenta stoa-capture → "command not found" → exit 127 → nenhum log).

Fix

Voltar pra caminho absoluto, mas portável (não hardcoded ao usuário "zeno"):

:onclick "~/.local/bin/stoa-capture ${capture-mode} ${capture-type} ${capture-delay}"

sh expande o til no início de palavra mesmo dentro de uma string -c, então resolve corretamente pra $HOME/.local/bin/stoa-capture de qualquer usuário.

Test plan

  • git pull && eww reload (fechar e reabrir o widget se já estiver aberto, pra pegar o config novo)
  • 📷 Screen + disparo → arquivo em ~/Pictures/screenshots/
  • 📷 Selection → slurp + arquivo
  • 🎥 + disparo → gravação inicia, Print pra parar
  • Log mostra Script called with args: screen screenshot 0 (ou similar) ao clicar o botão

Generated by Claude Code

The previous PR replaced the hardcoded /home/zeno/.local/bin/stoa-capture
with the unqualified "stoa-capture", relying on PATH. That works from
the user's interactive zsh (which has ~/.local/bin in PATH via .zshrc)
but eww spawns commands via /bin/sh -c, and that shell inherits only
the environment Hyprland was started with — not user shell rc files —
so ~/.local/bin isn't on PATH. Result: clicking the capture button
silently does nothing, with no log entry produced because the script
itself never executes. Manual invocation from the terminal worked
(zsh has the right PATH), which is what made the bug hard to pin down.

Use \"~/.local/bin/stoa-capture\" in the onclick. sh expands a leading
tilde during word expansion even from inside a -c string, so this
resolves to the linked install path under any user's home.
@VictorGSchneider VictorGSchneider self-assigned this May 12, 2026
@VictorGSchneider VictorGSchneider merged commit 697d417 into main May 12, 2026
1 check passed
@VictorGSchneider VictorGSchneider deleted the claude/fix-screenshot-widget-Wiz6D branch May 12, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants