78 lines
1.9 KiB
Bash
78 lines
1.9 KiB
Bash
#!/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
|
|
|
|
########## init config #########
|
|
if [[ ! -f ~/.config/workspace.conf ]]; then
|
|
mkdir -p ~/.config
|
|
cp config/workspace.conf ~/.config
|
|
fi
|
|
while read -r line; do
|
|
param="${line::-1}"
|
|
if ! grep -qE "^$param=.+" ~/.config/workspace.conf; then
|
|
echo "ERROR: ~/.config/workspace.conf - missing $param"
|
|
CONFIG_INVALID=1
|
|
fi
|
|
done < config/workspace.conf
|
|
[[ $CONFIG_INVALID ]] && exit 1
|
|
################################
|
|
|
|
####### file structure #########
|
|
USER_DIRS=(
|
|
##### xdg #####
|
|
~/.config # bkp=weak
|
|
~/.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 #############
|
|
gomplate --input-dir config \
|
|
--output-map "$HOME/.config/{{ .in | strings.ReplaceAll \".tmpl\" \"\" }}" \
|
|
--exclude-processing "!*.tmpl" \
|
|
--plugin jq=/bin/jq \
|
|
-c theme=config/theme.json \
|
|
-c user="file:///$HOME/.config/workspace.conf?type=application/x-env" \
|
|
--exclude /workspace.conf
|
|
|
|
ln -sf ~/.config/bash/bashrc ~/.bashrc
|
|
ln -sf ~/.config/profile ~/.profile
|
|
################################
|
|
|
|
############# data ############
|
|
cp -rf data/* ~/.local/share
|
|
###############################
|
|
|
|
swaymsg reload || true
|
|
|
|
echo ok
|