From bb41767cbad00bab4f1824f4e0754cc7abd98c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Thu, 15 Oct 2026 10:37:14 +0200 Subject: [PATCH] fix: a link opens lazysecrets with your cache and next to your running instances (#71) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The link handler's window starts with an app's minimal environment, and only PATH, the config locations and XDG_CONFIG_HOME/XDG_STATE_HOME were carried into it. With XDG_CACHE_HOME or XDG_RUNTIME_DIR set, lazysecrets opened from a link used another cache file and didn't see running instances' sockets; on Linux, without XDG_DATA_HOME it looked for its desktop entry in the wrong place. `handler install` now records those three too: run it again to pick them up. Reviewed-on: https://git.kebcloud.no/keb/lazysecrets/pulls/71 Co-authored-by: Karl-Einar Bergstrøm --- docs/sharing.md | 7 ++++--- internal/linkhandler/terminal.go | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/sharing.md b/docs/sharing.md index 5145e84..80336fa 100644 --- a/docs/sharing.md +++ b/docs/sharing.md @@ -143,9 +143,10 @@ turns the question off too. link then opens a new window of the terminal you ran it in, with lazysecrets on that link. It recognises kitty, Ghostty, WezTerm, iTerm2, Terminal.app, Alacritty, GNOME Terminal, Konsole and foot, also inside -tmux; `--terminal NAME` picks another. It records your `PATH` and config -locations, since apps start without your shell's environment (and so -without `az`): run it again after moving lazysecrets or changing those. +tmux; `--terminal NAME` picks another. It records your `PATH`, config +locations and XDG directories, since apps start without your shell's +environment (and so without `az`): run it again after moving lazysecrets +or changing those. - macOS: a small background app, `~/Applications/Lazysecrets Links.app` - Linux: a desktop entry claiming `x-scheme-handler/lazysecrets`, set as diff --git a/internal/linkhandler/terminal.go b/internal/linkhandler/terminal.go index 536de7b..6776f37 100644 --- a/internal/linkhandler/terminal.go +++ b/internal/linkhandler/terminal.go @@ -166,9 +166,11 @@ func Executable() (string, error) { // passEnv lists the variables carried from the install's environment to // lazysecrets in the new window: apps start with a minimal environment, -// without Homebrew's PATH (so no az) or the user's config locations. +// without Homebrew's PATH (so no az) or the user's XDG directories, so +// the window would use another cache and miss running instances' sockets. var passEnv = []string{ - "PATH", "LAZYSECRETS_CONFIG_FILE", "LAZYSECRETS_ICONS", "XDG_CONFIG_HOME", "XDG_STATE_HOME", + "PATH", "LAZYSECRETS_CONFIG_FILE", "LAZYSECRETS_ICONS", + "XDG_CONFIG_HOME", "XDG_STATE_HOME", "XDG_CACHE_HOME", "XDG_RUNTIME_DIR", "XDG_DATA_HOME", "AZURE_CONFIG_DIR", "DATABRICKS_CONFIG_FILE", }