From 102e2834b64d4940237fe77586e68ae940438796 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Mon, 6 Mar 2023 20:18:49 +0100 Subject: [PATCH] Honor `XDG_CONFIG_HOME` ENV variable Following XDG Spec: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html --- src/ameba/config.cr | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ameba/config.cr b/src/ameba/config.cr index 481d3bda..55d57d86 100644 --- a/src/ameba/config.cr +++ b/src/ameba/config.cr @@ -24,9 +24,10 @@ class Ameba::Config json: Formatter::JSONFormatter, } - DEFAULT_PATHS = { - "~/.ameba.yml", - "~/.config/ameba/config.yml", + XDG_CONFIG_HOME = ENV.fetch("XDG_CONFIG_HOME", "~/.config") + DEFAULT_PATHS = { + Path["~/.ameba.yml"], + Path[XDG_CONFIG_HOME] / "ameba/config.yml", } FILENAME = ".ameba.yml" DEFAULT_PATH = Path[Dir.current] / FILENAME