Fix command executor

This commit is contained in:
ryan 2025-08-10 20:43:31 -07:00
parent 983fc1cd29
commit 0677fe39dd

View File

@ -199,17 +199,25 @@ defmodule Systant.CommandExecutor do
# Get current environment
env = System.get_env()
# Ensure we have a proper PATH that includes system binaries
system_path = "/run/current-system/sw/bin:/usr/local/bin:/usr/bin:/bin"
current_path = Map.get(env, "PATH", "")
full_path = if current_path == "", do: system_path, else: "#{current_path}:#{system_path}"
# Start with enhanced environment
enhanced_env = Map.put(env, "PATH", full_path)
# If running as root, add Wayland session environment for user commands
if System.get_env("USER") == "root" do
# Find the user's Wayland session info
case find_user_wayland_session() do
{:ok, wayland_env} ->
Map.merge(env, wayland_env)
Map.merge(enhanced_env, wayland_env)
{:error, _reason} ->
env
enhanced_env
end
else
env
enhanced_env
end
end