Merge pull request #6939 from basecamp/fix-shell-succeeds-hyprland
Fix o.shell_succeeds() always returning false inside Hyprland
This commit is contained in:
@@ -18,9 +18,20 @@ local function file_exists(path)
|
|||||||
return false
|
return false
|
||||||
end
|
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)
|
function o.shell_succeeds(command)
|
||||||
local ok, _, code = os.execute(command .. " >/dev/null 2>&1")
|
-- Subshell, so the redirection covers every command rather than binding to
|
||||||
return ok == true or ok == 0 or code == 0
|
-- 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
|
end
|
||||||
|
|
||||||
function o.cmd_present(command)
|
function o.cmd_present(command)
|
||||||
|
|||||||
Reference in New Issue
Block a user