From 5c4c5f424472212d0e6fc3f1e50d8a9afc6887c9 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 31 Oct 2022 00:03:35 +0100 Subject: moved configuration from scripts to external files --- install.sh | 60 +++++++++++++++++++++++++++--------------------------------- 1 file changed, 27 insertions(+), 33 deletions(-) (limited to 'install.sh') diff --git a/install.sh b/install.sh index 55086d1..b5a7b38 100755 --- a/install.sh +++ b/install.sh @@ -1,45 +1,39 @@ #!/bin/bash -#['name']='install location relative to $HOME' -declare -A CONFIGS -CONFIGS=( ["sway"]=".config" - ["alacritty"]=".config" - ["polybar"]=".config" - ["powerline"]=".config" - ["nvim"]=".config" - ["termite"]=".config" - ["twmn"]=".config" - ["picom"]=".config" - ["i3"]=".config" - ["termux.properties"]=".termux" - ["bspwm"]=".config" - ["sxhkd"]=".config" - ["deadd"]=".config" - ["rofi"]=".config" - ["autoload.cfg"]=".local/share/Steam/steamapps/common/Counter-Strike Global Offensive/csgo/cfg/" - [".vim"]="." - [".xinitrc"]="." - [".bashrc"]="." - [".Xresources"]="." - [".radare2rc"]="." - [".bash_profile"]="." - [".stack"]="." - ["gpg-agent.conf"]=".gnupg" - ) - -declare -A SETS -SETS=( ["base"]=".vim .bashrc .bash_profile" - ["desktop"]="base termite picom i3 deadd polybar .xinitrc .Xresources" - ) +function fail(){ + EXCODE=$1 + shift + echo "$@" >&2 + exit "$EXCODE" +} WORKDIR=$(realpath "$(dirname "$0")") -cd "$WORKDIR" || (echo cd failed; exit 1) +cd "$WORKDIR" || fail 1 "The working directory could not be determined." echo "Working in $WORKDIR" echo "Homedir is $HOME" # === CODE BELOW HERE === -source "lib/funcs.sh" || exit 1 +source "lib/funcs.sh" || fail 1 "Failed to load components" + +if [ ! -f "config.csv" ] || [ ! -f "sets.csv" ]; then + # TODO Create them + fail 1 "Configuration files do not exist" +fi + +#['name']='install location relative to $HOME' +declare -A CONFIGS +while IFS=";" read -r CFG DEST _; do + CONFIGS[$CFG]="$DEST" +done < config.csv +unset CFG DEST + +#['name']='list of keys of CONFIGS (or SETS; Beware of BRB)' +declare -A SETS +while IFS=";" read -r SET PKGS _; do + SETS[$SET]="$PKGS" +done < sets.csv +unset SET PKGS if [ $# -eq 0 ]; then cat << EOF -- cgit v1.2.3