workspace/arch-user/install.sh
2025-03-29 16:07:54 +00:00

64 lines
1.6 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
####### file structure #########
mkdir -p \
~/.config ~/.local/bin ~/.local/share ~/.cache \
~/tmp ~/know ~/dev ~/dl
################################
########## 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
# 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