]> git.ekhem.eu.org Git - guix.git/commitdiff
[bash] Define XDG base directories.
authorJakub Czajka <jakub@ekhem.eu.org>
Sat, 28 May 2022 15:44:37 +0000 (17:44 +0200)
committerJakub Czajka <jczajka@google.com>
Sun, 24 Dec 2023 18:53:07 +0000 (19:53 +0100)
XDG base directory standard [1] defines environment variables with
important paths in user home directory. For example, XDG_CONFIG_HOME
points to a directory with configuration files.

Many programs respect the XDG base directory specification. For
example, git looks for it dotfile as either $HOME/.gitconfig or
$XDG_CONFIG_HOME/git/config. Therefore, XDG environment variables
should be defined early during startup.

This commit adds 10-xdg.sh which defines XDG base directory
variables. Prefix '10-' ensures that the files will be sourced by
~/.profile before other files in ~/.config/profile.d.

[1] https://specifications.freedesktop.org/basedir-spec

bash/.config/profile.d/10-xdg.sh [new file with mode: 0644]

diff --git a/bash/.config/profile.d/10-xdg.sh b/bash/.config/profile.d/10-xdg.sh
new file mode 100644 (file)
index 0000000..ba87c5d
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright (c) 2022 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+#
+# 10-xdg.sh - XDG Base Directory environment variables.
+
+export XDG_CONFIG_DIRS="/etc/xdg:${XDG_CONFIG_DIRS}"
+export XDG_CACHE_HOME="${HOME}/.cache"
+export XDG_CONFIG_HOME="${HOME}/.config"
+export XDG_DATA_DIRS="/usr/local/share/:/usr/share/:${XDG_DATA_DIRS}"
+export XDG_DATA_HOME="${HOME}/.local/share"
+export XDG_DESKTOP_DIR="${HOME}"
+export XDG_LOG_HOME="${HOME}/.local/var/log"
+export XDG_STATE_HOME="${HOME}/.local/state"