From ae583e96d3929be317b3efb8ee5139fb11310bad Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Tue, 26 Aug 2025 22:55:45 +1000 Subject: [PATCH] Support `XDG_CONFIG_HOME`/`XDG_DATA_HOME` on Windows (#2119) --- doc.md | 2 ++ doc.txt | 2 ++ lf.1 | 2 ++ os_windows.go | 12 ++++++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc.md b/doc.md index 3b3d0f6d..74a97e8f 100644 --- a/doc.md +++ b/doc.md @@ -366,9 +366,11 @@ You can configure these locations with the following variables given with their Windows %LF_CONFIG_HOME% + %XDG_CONFIG_HOME% %APPDATA% %LF_DATA_HOME% + %XDG_DATA_HOME% %LOCALAPPDATA% A sample configuration file can be found at diff --git a/doc.txt b/doc.txt index 70add143..b01705ae 100644 --- a/doc.txt +++ b/doc.txt @@ -359,9 +359,11 @@ with their order of precedences and their default values: Windows %LF_CONFIG_HOME% + %XDG_CONFIG_HOME% %APPDATA% %LF_DATA_HOME% + %XDG_DATA_HOME% %LOCALAPPDATA% A sample configuration file can be found at diff --git a/lf.1 b/lf.1 index 23b052c7..42104fe7 100644 --- a/lf.1 +++ b/lf.1 @@ -398,9 +398,11 @@ Unix Windows %LF_CONFIG_HOME% + %XDG_CONFIG_HOME% %APPDATA% %LF_DATA_HOME% + %XDG_DATA_HOME% %LOCALAPPDATA% .EE .PP diff --git a/os_windows.go b/os_windows.go index ab25267a..6b897d27 100644 --- a/os_windows.go +++ b/os_windows.go @@ -74,7 +74,11 @@ func init() { Username: username, } - config := cmp.Or(os.Getenv("LF_CONFIG_HOME"), os.Getenv("APPDATA")) + config := cmp.Or( + os.Getenv("LF_CONFIG_HOME"), + os.Getenv("XDG_CONFIG_HOME"), + os.Getenv("APPDATA"), + ) gConfigPaths = []string{ filepath.Join(os.Getenv("ProgramData"), "lf", "lfrc"), @@ -91,7 +95,11 @@ func init() { filepath.Join(config, "lf", "icons"), } - data := cmp.Or(os.Getenv("LF_DATA_HOME"), os.Getenv("LOCALAPPDATA")) + data := cmp.Or( + os.Getenv("LF_DATA_HOME"), + os.Getenv("XDG_DATA_HOME"), + os.Getenv("LOCALAPPDATA"), + ) gFilesPath = filepath.Join(data, "lf", "files") gMarksPath = filepath.Join(data, "lf", "marks")