diff --git a/default/hypr/envs.lua b/default/hypr/envs.lua index 96262454..08a93048 100644 --- a/default/hypr/envs.lua +++ b/default/hypr/envs.lua @@ -24,6 +24,25 @@ hl.env("XDG_SESSION_DESKTOP", "Hyprland") -- Use XCompose file. hl.env("XCOMPOSEFILE", paths.home .. "/.XCompose") +-- Propagate OMARCHY_PATH and PATH to processes spawned by Hyprland (keybinds, +-- dispatchers, autostart). hyprctl setenv doesn't reach the env captured for +-- bind exec at config-load time, so omarchy-dev-link reaches this via +-- hyprctl reload re-running envs.lua with the new paths.omarchy_path. +hl.env("OMARCHY_PATH", paths.omarchy_path) + +-- Prepend $OMARCHY_PATH/bin to PATH, deduping any prior occurrence so +-- reloads don't accumulate duplicates. +local bin_dir = paths.omarchy_path .. "/bin" +local current_path = os.getenv("PATH") or "/usr/local/bin:/usr/bin" +local kept = {} +for entry in current_path:gmatch("[^:]+") do + if entry ~= bin_dir then + table.insert(kept, entry) + end +end +table.insert(kept, 1, bin_dir) +hl.env("PATH", table.concat(kept, ":")) + hl.config({ xwayland = { force_zero_scaling = true, diff --git a/default/hypr/paths.lua b/default/hypr/paths.lua index 4e2d2428..27498186 100644 --- a/default/hypr/paths.lua +++ b/default/hypr/paths.lua @@ -4,9 +4,30 @@ local home = os.getenv("HOME") +-- Resolve OMARCHY_PATH with omarchy-dev-link awareness. If /etc/omarchy.conf +-- exists it wins over the process env, so dev-link takes effect even when +-- Hyprland's own env is stale (the launching session never re-read the conf). +local function read_dev_link_omarchy_path() + local f = io.open("/etc/omarchy.conf", "r") + if not f then return nil end + local value + for line in f:lines() do + local v = line:match('^%s*export%s+OMARCHY_PATH=%s*"?([^"\n]+)"?') + if v and #v > 0 then + value = v + end + end + f:close() + return value +end + +local omarchy_path = read_dev_link_omarchy_path() + or os.getenv("OMARCHY_PATH") + or (home .. "/.local/share/omarchy") + return { home = home, config_home = os.getenv("XDG_CONFIG_HOME") or (home .. "/.config"), state_home = os.getenv("XDG_STATE_HOME") or (home .. "/.local/state"), - omarchy_path = os.getenv("OMARCHY_PATH") or (home .. "/.local/share/omarchy"), + omarchy_path = omarchy_path, }