Environment


System wide

Load user environment from profile

#+begin_src sh :tangle (if noninteractive "no" "/sudo::/etc/profile.d/env.sh")
# User specified environment
if [ -d ~/.config/environment.d ]; then
        for rc in ~/.config/environment.d/*; do
                if [ -f "$rc" ]; then
                        . "$rc"
                fi
        done
fi

unset rc

Environment.d

Systemd’s environment.d(5) will read all variables from ~/.config/environment.d/*.conf. This section writes variables to that file.

Define XDG Home dirs

Make sure the XDG_ variables are set:

XDG_DATA_HOME="$HOME/.local/share"
XDG_CONFIG_HOME="$HOME/.config"
XDG_CACHE_HOME="$HOME/.cache"

Extend $PATH

PATH="$HOME/.local/bin":$PATH

Default tools

Editor

Emacs is the $EDITOR.

EDITOR="emacsclient"

Terminal

Set the preferred terminal emulator.

TERMINAL=/usr/bin/foot

Zsh

Make zsh find it’s RC files. Although zsh will not find the environments file automagically. Fo

ZDOTDIR="$XDG_CONFIG_HOME/zsh"

Tools

Docker

DOCKER_CONFIG="$XDG_CONFIG_HOME/docker"
MACHINE_STORAGE_PATH="$XDG_DATA_HOME/docker-machine"

Golang

GOPATH="$XDG_DATA_HOME/go"

And add it to the PATH.

PATH=$GOPATH/bin:$PATH

Rust

CARGO_HOME="$XDG_DATA_HOME/cargo"

And add it to the PATH.

PATH=$CARGO_HOME/bin:$PATH
  • Rustup
    RUSTUP_HOME="$XDG_CONFIG_HOME/rustup"
    

Yarn

Add Yarn bin dir to PATH.

command -v yarn > /dev/null && export PATH=$(yarn global bin):$PATH

GnuPG

GNUPGHOME="$XDG_DATA_HOME/gnupg"

Gem

GEM_HOME="${XDG_DATA_HOME}"/gem
GEM_SPEC_CACHE="$XDG_CACHE_HOME/gem"

IRB   ruby

IRBRC="$XDG_CONFIG_HOME/irb/irbrc"

Bundler   ruby

BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME/bundle"
BUNDLE_USER_CACHE="$XDG_CACHE_HOME/bundle"
BUNDLE_USER_PLUGIN="$XDG_DATA_HOME/bundle"
BUNDLE_PATH="vendor/bundle"

Solargraph

SOLARGRAPH_CACHE="$XDG_CACHE_HOME/solargraph"

Less

LESSKEY="$XDG_CONFIG_HOME/less/lesskey"
LESSHISTFILE="$XDG_CACHE_HOME/less/history"

Vim

VIMINIT="set viminfo+='1000,n$XDG_DATA_HOME/vim/viminfo'"

PostgreSQL

PSQLRC="$XDG_CONFIG_HOME/pg/psqlrc"
PSQL_HISTORY="$XDG_CACHE_HOME/pg/psql_history"
PGPASSFILE="$XDG_CONFIG_HOME/pg/pgpass"
#PGSERVICEFILE="$XDG_CONFIG_HOME/pg/pg_service.conf"

Asdf

asdf is used by the gitlab-development-kit.

ASDF_CONFIG_FILE="$XDG_CONFIG_HOME/asdf/asdfrc"
ASDF_DATA_DIR="$XDG_DATA_HOME/asdf"

Ansible

ANSIBLE_HOME="$XDG_DATA_HOME/ansible"

Lolcommits

Tell lolcommits which device to use: HD Pro Webcam C920.

Check which devices are available with:

v4l2-ctl --list-devices
LOLCOMMITS_DEVICE=$(v4l2-ctl --list-devices | grep -A1 C920 | tail -n1 | tr -d "\s\t")

Qt & KDE

Make sure the icons are shown:

[ "$XDG_CURRENT_DESKTOP" = "KDE" ] || [ "$XDG_CURRENT_DESKTOP" = "GNOME" ] || export QT_QPA_PLATFORMTHEME="qt5ct"

And that they are not too big:

#XDG_CURRENT_DESKTOP=KDE
KDE_SESSION_VERSION=5
QT_AUTO_SCREEN_SCALE_FACTOR=0
QT_FONT_DPI=120

Password store

Encrypt the passwords in password store ASCII armored.

PASSWORD_STORE_GPG_OPTS=--armor

Notmuch

Locate notmuch config:

NOTMUCH_CONFIG=$XDG_CONFIG_HOME/notmuch/config

Wayland

From: https://github.com/swaywm/sway/issues/5008#issuecomment-665972776

# Needed for xdg-desktop-portal
XDG_CURRENT_DESKTOP=sway
# this may fix external monitor problem
WLR_DRM_NO_MODIFIERS=1

# force wayland backend for bemenu
BEMENU_BACKEND=wayland

# Force Wayland backend for qt5 apps
QT_QPA_PLATFORM=wayland
QT_WAYLAND_DISABLE_WINDOWDECORATION=1

# general
XDG_SESSION_TYPE=wayland

Firefox

Force Firefox to use Wayland.

MOZ_DBUS_REMOTE=1
MOZ_ENABLE_WAYLAND=1