mirror of
https://github.com/frebib/dotfiles.git
synced 2024-06-14 12:57:23 +00:00
systemd: replace profile.service with systemd-environment.d generator
This moves loading of the environment variables out of the normal service startup flow and has systemd load the variables early. Shim ZSH to load the environment.d configuration when running without systemd. Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
parent
322adb478a
commit
521f462141
@ -4,7 +4,8 @@
|
||||
To get started, clone this repo and link the relevant files/directories
|
||||
|
||||
```shell
|
||||
git clone https://github.com/frebib/dotfiles.git ~/.config/dotfiles
|
||||
ln -sfv .config/dotfiles/* .config/
|
||||
ln -sfv .config/dotfiles/profile .zprofile
|
||||
git clone https://github.com/frebib/dotfiles.git ~/.config
|
||||
ln -sfv .config/zsh/.zshenv ~
|
||||
# if it is not already "enabled", make sure the systemd-environment.d generator is active
|
||||
sudo ln -sfv /lib/systemd/user-environment-generators/30-systemd-environment-d-generator /lib/systemd/user-generators/
|
||||
```
|
||||
|
34
environment.d/10-profile.conf
Normal file
34
environment.d/10-profile.conf
Normal file
@ -0,0 +1,34 @@
|
||||
LC_ALL="en_GB.UTF-8"
|
||||
LANG="en_GB.UTF-8"
|
||||
LC_NUMERIC="en_GB"
|
||||
|
||||
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
|
||||
EDITOR="vim"
|
||||
VISUAL="vim"
|
||||
|
||||
# Override paths for non-compliant programs
|
||||
# https://wiki.archlinux.org/index.php/XDG_Base_Directory_support
|
||||
|
||||
ADOTDIR="$XDG_DATA_HOME/zsh/antigen"
|
||||
CARGO_HOME="$XDG_DATA_HOME/cargo"
|
||||
GNUPGHOME="$XDG_CONFIG_HOME/gnupg"
|
||||
GOPATH="$XDG_DATA_HOME/go"
|
||||
NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc"
|
||||
#PASSWORD_STORE_DIR="$XDG_DATA_HOME/pass"
|
||||
PYTHONHISTFILE="$XDG_DATA_HOME/python/histfile"
|
||||
RUSTUP_HOME="$XDG_DATA_HOME/rustup"
|
||||
TERMINFO="$XDG_DATA_HOME/terminfo"
|
||||
TERMINFO_DIRS="$XDG_DATA_HOME/terminfo:/usr/share/terminfo"
|
||||
VIMDIR="$XDG_CONFIG_HOME/vim"
|
||||
VIMRC="$VIMDIR/vimrc"
|
||||
VIMINIT=":so $VIMRC"
|
||||
WEECHAT_HOME="$XDG_CONFIG_HOME/weechat"
|
||||
XINITRC="$XDG_CONFIG_HOME/X11/xinitrc"
|
||||
ZDOTDIR="$XDG_CONFIG_HOME/zsh"
|
||||
|
||||
PATH="${PATH}:/sbin:/usr/sbin:${XDG_CONFIG_HOME}/scripts:${GOPATH}/bin"
|
||||
|
||||
# vim: ft=sh
|
56
profile
56
profile
@ -1,56 +0,0 @@
|
||||
export LC_ALL=en_GB.UTF-8
|
||||
export LANG=en_GB.UTF-8
|
||||
export LC_NUMERIC=en_GB
|
||||
|
||||
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
export XDG_LOCAL_HOME="$HOME/.local"
|
||||
|
||||
mkdir -p "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME" "$XDG_DATA_HOME" "$XDG_LOCAL_HOME"
|
||||
|
||||
case "$(basename "$(readlink -f /proc/$$/exe)")" in
|
||||
zsh) thisfile="$(readlink -f "${(%):-%N}")";;
|
||||
bash) thisfile="$(readlink -f "${BASH_SOURCE[0]}")";;
|
||||
*) thisfile="$(find /proc/$$/fd/ | xargs -n1 -r readlink -f | grep profile | head -n1)";;
|
||||
esac
|
||||
|
||||
export EDITOR="vim"
|
||||
export VISUAL="vim"
|
||||
|
||||
# Override paths for non-compliant programs
|
||||
# https://wiki.archlinux.org/index.php/XDG_Base_Directory_support
|
||||
|
||||
export ADOTDIR="$XDG_DATA_HOME/zsh/antigen"
|
||||
export CARGO_HOME="$XDG_DATA_HOME/cargo"
|
||||
export GNUPGHOME="$XDG_CONFIG_HOME/gnupg"
|
||||
export GOPATH="$XDG_DATA_HOME/go"
|
||||
export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc
|
||||
export PASSWORD_STORE_DIR="$XDG_DATA_HOME/pass"
|
||||
export PYTHONHISTFILE="$XDG_DATA_HOME/python/histfile"
|
||||
export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
|
||||
export TERMINFO="$XDG_DATA_HOME/terminfo"
|
||||
export TERMINFO_DIRS="$XDG_DATA_HOME/terminfo:/usr/share/terminfo"
|
||||
export VIMDIR="$XDG_CONFIG_HOME/vim"
|
||||
export VIMRC="$VIMDIR/vimrc"
|
||||
export VIMINIT=":so $VIMRC"
|
||||
export WEECHAT_HOME="$XDG_CONFIG_HOME/weechat"
|
||||
export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc"
|
||||
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
|
||||
|
||||
export DOTFILES="$(dirname "${thisfile:-$XDG_CONFIG_HOME/dotfiles/.profile}")"
|
||||
export PATH="${PATH}:/sbin:/usr/sbin:$DOTFILES/scripts:$GOPATH/bin"
|
||||
|
||||
exists() { which $@ 0<&- 1>/dev/null 2>/dev/null; }
|
||||
|
||||
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && exists dbus-launch; then
|
||||
eval $(dbus-launch --sh-syntax --exit-with-session)
|
||||
fi
|
||||
|
||||
# Execute this after updating dbus/systemd environment
|
||||
# Source secret keys and values into environment
|
||||
if [ -f "$XDG_CONFIG_HOME/secrets" ]; then
|
||||
set -o allexport
|
||||
source $XDG_CONFIG_HOME/secrets
|
||||
set +o allexport
|
||||
fi
|
@ -1 +0,0 @@
|
||||
/home/frebib/.config/systemd/user/profile.service
|
@ -2,7 +2,7 @@
|
||||
Description=i3 - an improved dynamic, tiling window manager
|
||||
Requires=xorg.target
|
||||
Before=graphical-session.target
|
||||
After=profile.service xprofile.service xorg.target
|
||||
After=xprofile.service xorg.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/i3
|
||||
|
@ -1,10 +0,0 @@
|
||||
[Unit]
|
||||
Description=Load profile environment into session
|
||||
Before=graphical-session-pre.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/sh -c '. $HOME/.config/dotfiles/profile && systemctl --user import-environment'
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
@ -1,7 +1,5 @@
|
||||
[Unit]
|
||||
Description=XBindKeys
|
||||
Requires=profile.service
|
||||
After=profile.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/xbindkeys -n -f $XDG_CONFIG_HOME/X11/xbindkeysrc
|
||||
|
@ -1,13 +1,12 @@
|
||||
[Unit]
|
||||
Description=Load Xorg configuration
|
||||
PartOf=xorg.target
|
||||
Requires=profile.service
|
||||
After=xorg.target profile.service
|
||||
After=xorg.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/bin/bash -c '. $XDG_CONFIG_HOME/X11/xprofile; systemctl --user import-environment'
|
||||
ExecStart=/bin/sh -c '. $XDG_CONFIG_HOME/X11/xprofile; systemctl --user import-environment'
|
||||
|
||||
[Install]
|
||||
WantedBy=xorg.target
|
||||
|
@ -1,7 +1,7 @@
|
||||
[Unit]
|
||||
Description=xsettingsd - provide settings to X11 applications
|
||||
Requires=xorg.target
|
||||
After=xorg.target profile.service
|
||||
After=xorg.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -c 'xsettingsd -c $XDG_CONFIG_HOME/xsettingsd/xsettingsd.local'
|
||||
|
3
zsh/.gitignore
vendored
3
zsh/.gitignore
vendored
@ -1,4 +1 @@
|
||||
/antigen/
|
||||
/log/
|
||||
/histfile
|
||||
/.zcompdump*
|
||||
|
5
zsh/.zshenv
Normal file
5
zsh/.zshenv
Normal file
@ -0,0 +1,5 @@
|
||||
set -o allexport
|
||||
. ~/.config/environment.d/*.conf
|
||||
set +o allexport
|
||||
|
||||
# vim: ft=sh
|
@ -149,7 +149,7 @@ ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]='fg=cyan'
|
||||
ZSH_HIGHLIGHT_STYLES[assign]='fg=green'
|
||||
ZSH_HIGHLIGHT_STYLES[redirection]='fg=cyan,bold'
|
||||
|
||||
source "$DOTFILES/aliases"
|
||||
source "$XDG_CONFIG_HOME/aliases"
|
||||
|
||||
# Source secret keys and values into environment
|
||||
if [ -f "$XDG_CONFIG_HOME/secrets" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user