fix: probe wpctl/pactl without noisy errors

This commit is contained in:
2025-12-05 00:58:36 +01:00
parent 8f33a65c74
commit 73cfcf93c8

View File

@@ -75,17 +75,27 @@ local function run_cmd(args)
return res.stdout or ""
end
local function probe_cmd(args)
local res = utils.subprocess({ args = args, cancellable = false })
if res and not res.error and res.status == 0 then
return res.stdout or ""
end
return nil
end
local function pick_volume_backend()
if state.volume_backend then
return state.volume_backend
end
local wp = run_cmd({ config.wpctl_path, "--version" })
local wp = probe_cmd({ config.wpctl_path, "status" })
or probe_cmd({ config.wpctl_path, "--help" })
if wp then
state.volume_backend = "wpctl"
dbg("using wpctl for volume")
return state.volume_backend
end
local pa = run_cmd({ config.pactl_path, "--version" })
local pa = probe_cmd({ config.pactl_path, "info" })
or probe_cmd({ config.pactl_path, "--version" })
if pa then
state.volume_backend = "pactl"
dbg("using pactl for volume")