From 7e76f825c724f4b1828e913a8f6554ae30db6919 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Mon, 16 Sep 2024 00:40:03 +0200 Subject: [PATCH] feat(setup): copy gtk-related config instead of symlinking --- setup.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index a06ee7e..a1517ef 100755 --- a/setup.sh +++ b/setup.sh @@ -43,8 +43,6 @@ SYMLINKS=( ".config/dunst" ".config/fish" ".config/frogminer" - ".config/gtk-3.0" - ".config/gtk-4.0" ".config/i3" ".config/i3status" ".config/lf" @@ -57,12 +55,18 @@ SYMLINKS=( ".local/bin" ".local/share/fonts" ".local/share/konsole" - ".gtkrc-2.0" ".xinit-scripts" ".xinitrc" ".Xresources" ) +typeset -a COPIES +COPIES=( + ".config/gtk-3.0" + ".config/gtk-4.0" + ".gtkrc-2.0" +) + typeset -A SYMLINK_MAP SYMLINK_MAP[zsh/rc]=".zshrc" @@ -160,6 +164,46 @@ create_symlink() { ln -s "$src" "$dst" } +copy_item() { + local src dst dst_parent + + if test -z "$1"; then + error "missing src argument:" + error "$0 $1 $2" + return 1 + fi + + if test -z "$2"; then + error "missing dst argument:" + error "$0 $1 $2" + return 1 + fi + + src="${SCRIPT_DIR}/$1" + dst="${DEST_DIR}/$2" + dst_parent="$(dirname -- "$dst")" + + if ! test -e "$src"; then + error "the following source path does not exist:" + error "$src" + return 1 + fi + + if ! test -d "$dst_parent"; then + echo "Creating $dst_parent" + mkdir -p "$dst_parent" + fi + + if test -e "$dst"; then + error "path already exists:" + error "${dst}" + return 1 + fi + + echo "Copying item: from $src to ${dst_parent}/" + cp -r "$src" "${dst_parent}/" +} + create_all_symlinks() { for link in "${SYMLINKS[@]}"; do create_symlink "$link" "$link" @@ -170,6 +214,12 @@ create_all_symlinks() { done } +copy_all_items() { + for item in "${COPIES[@]}"; do + copy_item "$item" "$item" + done +} + check_terminfo() { if ! infocmp tmux-256color > /dev/null; then error "Missing terminfo for tmux-256color. Try installing ncurses-term." @@ -222,6 +272,7 @@ else check_terminfo check_packages_installed create_all_symlinks + copy_all_items fi if $ERROR; then