From 0965ac2e4fa546afe476f2621530f0050d6d04e9 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 15 Aug 2026 01:43:14 -0700 Subject: [PATCH] Fix o.shell_succeeds() always returning false inside Hyprland 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 --- default/hypr/helpers.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/default/hypr/helpers.lua b/default/hypr/helpers.lua index 289afe90..d1affbc7 100644 --- a/default/hypr/helpers.lua +++ b/default/hypr/helpers.lua @@ -18,9 +18,20 @@ local function file_exists(path) return false end +-- Hyprland reaps its own children, so os.execute() can't retrieve an exit status +-- from inside the compositor. Read a marker off stdout instead. function o.shell_succeeds(command) - local ok, _, code = os.execute(command .. " >/dev/null 2>&1") - return ok == true or ok == 0 or code == 0 + -- Subshell, so the redirection covers every command rather than binding to + -- the last one and letting an earlier one write its own OK into the pipe. + local pipe = io.popen("( " .. command .. " ) >/dev/null 2>&1 && echo OK") + if not pipe then + return false + end + + local output = pipe:read("*a") or "" + pipe:close() + + return output:find("OK", 1, true) ~= nil end function o.cmd_present(command)