aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Kavanagh <rak@rak.ac>2024-01-05 15:13:55 -0500
committerRyan Kavanagh <rak@rak.ac>2024-01-05 15:30:51 -0500
commit0dc520ec4367e73849b667ab2efde950c87d18bf (patch)
treeddd533dde5f4c4387d7c66fa4815f11abc75ecdc
parentrak-meta (diff)
Improve environment var handling for shells and systemd
-rw-r--r--dot_config/environment.d/01_PATH.conf3
-rw-r--r--dot_config/environment.d/02_xdg-base-dirs4
-rw-r--r--dot_config/environment.d/02_xdg-base-dirs.conf4
-rw-r--r--dot_config/environment.d/03_locale.conf.tmpl6
-rw-r--r--dot_config/environment.d/03_locale.tmpl10
-rw-r--r--dot_config/sh/01_environment.d8
6 files changed, 21 insertions, 14 deletions
diff --git a/dot_config/environment.d/01_PATH.conf b/dot_config/environment.d/01_PATH.conf
new file mode 100644
index 0000000..e342e30
--- /dev/null
+++ b/dot_config/environment.d/01_PATH.conf
@@ -0,0 +1,3 @@
+PATH=${PATH:-/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games}
+PATH=${HOME}/.cargo/bin:${PATH}
+PATH=${HOME}/bin:${PATH}
diff --git a/dot_config/environment.d/02_xdg-base-dirs b/dot_config/environment.d/02_xdg-base-dirs
deleted file mode 100644
index 18acb96..0000000
--- a/dot_config/environment.d/02_xdg-base-dirs
+++ /dev/null
@@ -1,4 +0,0 @@
-export XDG_CACHE_HOME="${HOME}/.cache"
-export XDG_CONFIG_HOME="${HOME}/.config"
-export XDG_DATA_HOME="${HOME}/.local/share"
-export XDG_STATE_HOME="${HOME}/.local/state"
diff --git a/dot_config/environment.d/02_xdg-base-dirs.conf b/dot_config/environment.d/02_xdg-base-dirs.conf
new file mode 100644
index 0000000..6da8783
--- /dev/null
+++ b/dot_config/environment.d/02_xdg-base-dirs.conf
@@ -0,0 +1,4 @@
+XDG_CACHE_HOME=${HOME}/.cache
+XDG_CONFIG_HOME=${HOME}/.config
+XDG_DATA_HOME=${HOME}/.local/share
+XDG_STATE_HOME=${HOME}/.local/state
diff --git a/dot_config/environment.d/03_locale.conf.tmpl b/dot_config/environment.d/03_locale.conf.tmpl
new file mode 100644
index 0000000..86380d3
--- /dev/null
+++ b/dot_config/environment.d/03_locale.conf.tmpl
@@ -0,0 +1,6 @@
+LANG="{{ .locale_base}}.UTF-8"
+LC_TIME="en_GB.UTF-8"
+# force strict lexicographic sorting
+LC_COLLATE=C
+
+# vim: set ft=sh:
diff --git a/dot_config/environment.d/03_locale.tmpl b/dot_config/environment.d/03_locale.tmpl
deleted file mode 100644
index 7d73fb3..0000000
--- a/dot_config/environment.d/03_locale.tmpl
+++ /dev/null
@@ -1,10 +0,0 @@
-if ! export LANG=$(locale -a | grep -E -i "{{ .locale_base }}\.UTF-?8"); then
- if ! export LANG=$(locale -a | grep -E -i "C.UTF-?8"); then
- export LANG=C
- fi
-fi
-
-export LC_TIME="en_GB.UTF-8"
-export LC_COLLATE=C # force strict lexicographic sorting
-
-# vim: set ft=sh:
diff --git a/dot_config/sh/01_environment.d b/dot_config/sh/01_environment.d
new file mode 100644
index 0000000..eea2917
--- /dev/null
+++ b/dot_config/sh/01_environment.d
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+for f in ${HOME}/.config/environment.d/*; do
+ . $f
+ for VAR in $(sed -n '/^[^#]/ s/=.*//p' $f); do
+ export $VAR
+ done
+done