Skip to content

Fix o.shell_succeeds() always returning false inside Hyprland - #6939

Merged
ryanrhughes merged 1 commit into
quattrofrom
fix-shell-succeeds-hyprland
Aug 15, 2026
Merged

ryanrhughes merged 1 commit into
quattrofrom
fix-shell-succeeds-hyprland

Conversation

@dhh

@dhh dhh commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Hyprland reaps its own children, so os.execute() gets ECHILD from waitpid and never sees an exit status. Every call reported failure. Confirmed against the running compositor:

$ hyprctl repl 'return tostring(o.shell_succeeds("true"))'
false

The only callers are default/hypr/nvidia.lua, so NVD_BACKEND, LIBVA_DRIVER_NAME and __GLX_VENDOR_LIBRARY_NAME were never set on NVIDIA hardware.

Reads a marker off stdout instead, which does not depend on reaping the child. io.popen's own close status is unreliable for the same reason, so it is deliberately not checked.

Verified inside the running compositor (true → true, false → false) and standalone, where a command that writes its own output to stdout still reports correctly.

Note this cannot be caught by a unit test: test/shell.d/hyprland-default-config-test.sh runs under standalone lua, where os.execute behaves normally.

Closes #6914

— 🤖 Claude, posting on behalf of @dhh

Copilot AI balanced review requested due to automatic review settings August 15, 2026 09:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Hyprland NVIDIA detection by deriving shell success from a stdout marker instead of an unavailable child exit status.

Changes:

  • Replaces os.execute() status handling with io.popen().
  • Detects successful commands through an OK marker.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread default/hypr/helpers.lua Outdated
function o.shell_succeeds(command)
local ok, _, code = os.execute(command .. " >/dev/null 2>&1")
return ok == true or ok == 0 or code == 0
local pipe = io.popen(command .. " >/dev/null 2>&1 && echo OK")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, and it reproduced exactly as described — o.shell_succeeds("printf OK; false") returned true, because the redirection bound only to false and printf wrote the marker straight into the pipe.

Fixed by running the command in a subshell, so the redirection covers all of it and only the helper's own marker can reach stdout:

local pipe = io.popen("( " .. command .. " ) >/dev/null 2>&1 && echo OK")

A subshell rather than a { ...; } group so a command ending in & stays valid. Re-tested against printf OK; false, echo OK && false, sh -c "exit 3", true & and a missing command, all correct now, and re-confirmed inside the running compositor.

No live caller was affected — the only callers are the simple commands in hypr/nvidia.lua — but the helper is general and the flaw was real.

— 🤖 Claude, posting on behalf of @dhh

Hyprland reaps its own children, so os.execute() gets ECHILD from waitpid and
never sees an exit status. Every call reported failure, which meant the NVIDIA
env detection in hypr/nvidia.lua never set NVD_BACKEND, LIBVA_DRIVER_NAME or
__GLX_VENDOR_LIBRARY_NAME. Read a marker off stdout instead.

Closes #6914

Co-Authored-By: Claude Opus 5 <[email protected]>
Copilot AI review requested due to automatic review settings August 15, 2026 14:12
@dhh
dhh force-pushed the fix-shell-succeeds-hyprland branch from 5bb3ce4 to 0965ac2 Compare August 15, 2026 14:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@dhh
dhh requested a review from ryanrhughes August 15, 2026 15:12
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.

o.shell_succeeds() always returns false inside Hyprland, so NVIDIA env detection never fires

4 participants