diff --git a/scripts/touch-gestures.lua b/scripts/touch-gestures.lua index 54e7576..7ce2aab 100644 --- a/scripts/touch-gestures.lua +++ b/scripts/touch-gestures.lua @@ -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")