#!/bin/bash # config/ - configuration files (including shell and profile) # data/ - resource files used by configured system # bin/ - scripts used either by configured system or by user set -e cd "$(dirname "$0")" umask 002 [[ "$(id -u)" == "0" ]] && echo "ERROR: wrong user" >&1 && exit 1 ####### file structure ######### USER_DIRS=( ##### xdg ##### ~/.config ~/.local/bin # bkp=weak ~/.local/share # bkp=weak ~/.local/state ~/.cache # app ~/.local/state/sway ################ ##### user ##### # core knowledge base ~/know # bkp=true,roam=true # large blobs for knowledge base ~/know-lfs # Large blobs for knowledge base. bkp=weak # temp files with manual bulk cleanup ~/tmp # downloads ~/dl # bkp=weak # development - external vcs, tons of deps, etc. ~/dev # bkp=weak ################ ) mkdir -p "${USER_DIRS[@]}" ################################ ########## scripts ############# cp -rf bin/* ~/.local/bin ################################ ########### config ############# source config/theme.sh VARS=$(printenv | \ grep -E '^(THEME_.\w+)|(USER)=' | \ sed -e 's/[= ].*//g' | sed -e 's/^/\$/' | tr '\n' ' ' ) cp_subst() { mkdir -p "$(dirname "$2")" envsubst "$VARS" < "$1" > "$2" } # xdg cp -rf config/i3blocks ~/.config cp -rf config/git ~/.config cp -rf config/vim ~/.config cp -rf config/xkb ~/.config cp -rf config/swayidle ~/.config # non-xdg cp -rf config/bash ~/.config ln -sf ~/.config/bash/bashrc ~/.bashrc # templated cp_subst config/sway/config.tmpl ~/.config/sway/config cp_subst config/foot/foot.ini.tmpl ~/.config/foot/foot.ini cp_subst config/mako/config.tmpl ~/.config/mako/config cp_subst config/qutebrowser/config.py.tmpl ~/.config/qutebrowser/config.py # dynamic cp -rf config/profile.part ~/.profile # shellcheck disable=SC2129 echo -e "\n# GENERATED" >> ~/.profile sed '/^#/d' config/theme.sh >> ~/.profile sed '/^#/d' config/bemenu/config.sh >> ~/.profile ################################ ############# data ############ cp_subst data/qutebrowser/start.html.tmpl ~/.local/share/qutebrowser/start.html ############################### swaymsg reload || true echo ok