moved the generation of local environment variables to its own generator script
This commit is contained in:
parent
fa32f1be82
commit
ef6d56b2a8
4 changed files with 25 additions and 17 deletions
21
.local/bin/generate-env
Executable file
21
.local/bin/generate-env
Executable file
|
@ -0,0 +1,21 @@
|
|||
#! /bin/sh
|
||||
if [ -d /usr/lib/systemd/system-environment-generators ];
|
||||
then
|
||||
run-parts /usr/lib/systemd/user-environment-generators
|
||||
else
|
||||
cat "$HOME"/.config/environment.d/*
|
||||
fi | grep -v '#' | grep -v '^[[:space:]]*$' | while read -r cur_env; do export "${cur_env?}"; done
|
||||
|
||||
command -v ip >/dev/null 2>&1 &&
|
||||
{
|
||||
LOCAL_IP="$(ip route | sed -En '/.*linkdown/! s/.*src\s+([^ ]+)\s*/\1/p')"
|
||||
|
||||
export LOCAL_IP
|
||||
TARGET_FILE="$(readlink -f "${XDG_RUNTIME_DIR:-${TMPDIR:-$HOME}}")/local_ip"
|
||||
[ ! -r "$TARGET_FILE" ] && echo "$LOCAL_IP" > "$TARGET_FILE"
|
||||
}
|
||||
|
||||
# Make sure we include this part only once
|
||||
[ -n "$USER_ENVIRONMENT_GENERATORS" ] && return
|
||||
export USER_ENVIRONMENT_GENERATORS=1
|
||||
PATH="$HOME/.local/bin:$PATH"
|
Loading…
Add table
Add a link
Reference in a new issue